Reputation:
After the last training epoch, I get this output:
Epoch 100/100
89254/89254 - 24s - loss: 0.1935 - acc: 0.9281 - val_loss: 0.2182 - val_acc: 0.9219
But the problem is, once I conduct model.evaluate()
on training data and validation data, I get different results:
Train accuracy: 0.929661
Validation accuracy: 0.921859
How does this make sense? And why does parameter batch_size
exist for the model.evaluate()
function despite test mode? https://keras.io/models/model/#evaluate
If I have trained the model in batches, would I need to define the batch size for test mode as well?
Upvotes: 1
Views: 1408
Reputation: 56357
Of course it makes sense, to start, any metric/loss produced in the training set on the progress bar is computed as a running mean over training batches, where the weights are changing due to gradient descent. This means that training metrics will never match the ones computed with model.evaluate()
, as in that case weights are constant and not changing.
About validation metrics, they do match, its just that the keras
progress bar prints only four significant digits, and you printed more.
About batch size, I already commented that basically it has been answered here. Keras uses batches because you cannot make a prediction on a whole dataset at a time, that would probably use too much memory
Upvotes: 3