NLP Specilization-C3W1_Assignment-ValueError


Log_Perplexity Computation Error:

I think I received this error due to the dimension mismatch in which “preds” has a dimension of (2,1,7,3) (4D dimension) whereas “target” has a dimension of (2, 7). But preds should have a 3D dimension anyway. Also, collapsing the second dimension “1” to (2, 7, 3) of the shape of preds does not generate the right answer either. So, how to solve this issue anyway?

Np.sum here should be along the last axis!

1 Like

Oh, thank you so much!

1 Like