본문 바로가기
언어/ㄴPython

[python] randomly shuffle train data

by 공대우냉이 2016. 2. 19.

 

shuffleData.py


matData.mat


This code shuffle train data. We know that train data inputed randomly is efficient to train weight.

If you get typeError, you check type to 'trainLabel' variable.

And you fix 'addTrainLabel=numpy.array([trainLabel[0,ind[0:balance]]])' code to 'addTrainLabel=numpy.array(trainLabel[0,ind[0:balance]])'.

But, If you continously get typeError, you think about error and fix yourself please.


train data를 랜덤적으로 섞는 코드이다. 이것은 weight들을 학습하는데 더욱 효과적이기 때문에 인식률 상승을 위해 써줄 필요가 있다. 만약 typeError가 뜬다면 trainLabel이라는 변수의 변수 타입을 살펴보기 바란다.

만약 train data의 개수가 batch size로 나누어 떨어지지 않는다면 train data에서 랜덤적으로 선정된 몇개의 데이터로 batch size에 맞게 채워진다. 이것은 인식률에 크게 영향을 주지 않을 것이다. 어차피 epoch를 실행하면 같은 데이터를 수 백번이상 train 하므로 큰 영향이 없을 것이라고 판단했다.