Different values of mae on the same data!

HI.
Given a dataset valid_ds:

<PrefetchDataset shapes: ((None, 10, 224, 224, 3), (None, 5)), types: (tf.float32, tf.float32)>

I evaluate my model like this:

mse, mae = model.evaluate(valid_ds)
mao

It gives:

mae=0.9110

if i extracted the y_true from valid_ds like this:

y_true = np.concatenate([y, for x,y in valid_ds], axis=0)

Then i used mean_absolute_error from sklearn.metrics:

y_valid_pred = model.predict(valid_ds)
mae = mean_absolute_error(y_true, y_valid_pred)

I got a mae:

mae=0.8534

Can someone tell me why we have different values of mae?
Thank you

1 Like

Are you using batch size 1 in valid_ds? That’s the only thing I can really think of. It should be 1 for some metrics I think.

1 Like

You’ll be able to narrow it down if Instead of running over the whole dataset you work on just one batch.

model.evaluate

I always use return_dict=True, for clarity.