On training my network using model.fit() in Keras with loss='mean_squared_error' in model.compile():
model.compile(loss='mean_squared_error', optimizer=optimizers.Adam(decay=0.00001), metrics=['accuracy'])
hist=model.fit(X, Y, epochs=200, batch_size=2000, verbose=2, shuffle="batch", validation_data=(Xval,Yval))
I get this at the end:
Epoch 200/200 23s - loss: 1.2060 - acc: 0.5168 - val_loss: 1.5213 - val_acc: 0.5294
Now if I manually check the loss on the validation set by
pre=model.predict(Xval)
print(np.mean(np.square(pre-Yval)))
I get 1.4587 and not 1.5213.
Why are they different? Why am I not getting 1.5213 as calculated by model.fit()? Am I missing something here? Doesn't model.fit() go through the entire validation set?