Skip to content

Commit

Permalink
shuffle data before training
Browse files Browse the repository at this point in the history
Again, it is my misunderstand about `model.fit(shuffle=True)`, it means
"Whether to shuffle the samples at each epoch" ,but not "shuffle the
samples before spliting them into train-set and val-set".
  • Loading branch information
wepe committed May 25, 2015
1 parent c040753 commit 4757803
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions DeepLearning Tutorials/keras_usage/cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@
from keras.utils import np_utils, generic_utils
from six.moves import range
from data import load_data
import random




#加载数据
data, label = load_data()
#打乱数据
index = [i for i in range(len(data))]
random.shuffle(index)
data = data[index]
label = label[index]
print(data.shape[0], ' samples')

#label为0~9共10个类别,keras要求格式为binary class matrices,转化一下,直接调用keras提供的这个函数
Expand Down

0 comments on commit 4757803

Please sign in to comment.