I see that the MSE metric provided by the model.fit (history) is slightly different from the MSE calculated by model.evaluate?

Can anyone help?

# fit model
Hist = model_rna.fit(x_train, y_train,
                  validation_data=(x_val, y_val),

# get last trained mse
hist = pd.DataFrame(Hist.history)
mse_train = [i for i in np.array(hist['mse']).tolist()]

The result is 0.03789380192756653

# evaluate the trained model
model_rna.evaluate(x_train, y_train)

The result is: 5/5 [==============================] - 0s 4ms/step - loss: 0.0379 - mse: 0.0379 - acc: 0.0000e+00 [0.03786146640777588, 0.03786146640777588, 0.0]

If I do the "manual" calculation:

Sum_of_Squared_Errors= np.sum( (y_train - modelo_rna.predict(x_train))**2 )

The result is: 0.03786148292614872

This is exactly what I found via model.evaluate() but slightly different of History of model.fit().

Why am I finding this tiny difference?

My training and validation samples are fixed.


1 Answer 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.