Getting nan values when running the test model function in UNQ_C5

Hi~
I’m not sure what’s wrong.
The output value of np.log(preds) in the test_model function is all nan when I look at the array.

I’d appreciate some advice.

I’m not sure about that specific exercise. But, take a look at what the “preds” values are. If they are zeros, note that log(0) is undefined.

Hi @Nadle

One point of failure that I can see is that you use preds as a variable, while in the assignment you should work with pred variable name. That might be the cause (if you initialized preds to be all None and taking np.log of that is an error).

And as Tom mentioned you should look what preds is in the first place.

Cheers

I was getting nan values because I didn’t realize that the model output was a LogSoftmax value. Your advice to check the preds value was helpful! Thank you.

Thank you for your answer