C4W1 - compute_metrics Failed test case

Despite passing all the other unit tests and the values produced by that function always being correct, I keep getting the following error by the unit tests when trying to submit it:
Failed test case: mse has incorrect type. Expected: a subdtype of np.number, but got: <class ‘tensorflow.python.framework.ops.EagerTensor’>.

Is this an error on my part or in the unit test itself? I would assume that if the error was on my part, it would fail one of the later tests, but, again, all the other tests are fine.

I have saved the notebook and restarted the kernel several times just in case.

hi @swat6296

can I know how are you computing metrics?

assignment instruction mentions

You should use functions provided by tf.keras.losses to compute MSE and MAE errors.

did you by any chance forgot to apply numpy to the tf.keras.losses while computing metrics?

This can be resolved by calling the .numpy() method on the TensorFlow functions.

2 Likes

Ah, yes, that was absolutely correct. I was confused by the fact that there was no error, so didn’t assume .numpy() was needed at all.

2 Likes