i am using tensorflow and keras on colab i train with shuffled data but i met this strange accuracy with evaluate_generator with my training set that has 95% acc
if i did not shuffle my data with evaluate_generator
train_generator = train_datagen.flow_from_directory(
train_data_dir,
target_size=(img_width, img_height),
batch_size=32,
shuffle=False,
class_mode="sparse",
subset='training')
i get that
acc = model.evaluate_generator(train_generator, steps=2, verbose=1)
print(acc)
2/2 [==============================] - 1s 293ms/step - loss: 1.7815 - acc: 0.7344
[1.781482219696045, 0.734375]
but if i used shuffle like i did with training epochs
train_generator = train_datagen.flow_from_directory(
train_data_dir,
target_size=(img_width, img_height),
batch_size=32,
shuffle=True,
class_mode="sparse",
subset='training')
i got my acc back
acc = model.evaluate_generator(train_generator, steps=2, verbose=1)
print(acc)
2/2 [==============================] - 19s 9s/step - loss: 0.2059 - acc: 0.9219
[0.20589596964418888, 0.921875]
as i can not say i train model and got high accuracy then doing evaluate to my model by my train set i must get near accuracy to it ... same with my validation set
so why shuffling my data effect my evaluation of my model
(i trained model with shuffle)
edit my model : ResNet34
my classes number: 7
complie function :
model.compile(loss='sparse_categorical_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])
i used 10000 images dataset with split 0.2 rate 8000 images for train
and now i retrain my model(with non shuffled data) it is like shuffled data is complete strange than without shuffle , when i start training loss was too high and get smaller but this was model with training data and 26 epochs and acc > 90% and re-continue train with low acc and high loss