C3W1 Error in Exercise 5: Log perplexity


This is the error I’m getting however, I don’t understand why. Can someone let me know why this is happening?

Hi @N_Adhikari

Make sure that the axis parameter in your function is explicitly set to -1 ( the last axis of a multidimensional array can be accessed using -1 as the index) so that it dynamically adapts to the last axis, regardless of the shape of the input array. This generalization avoids the need for hardcoding and might resolve your issue!

Hope it helps! Feel free to ask if you need further assistance.

Thank you so much for your help!