Question about C3W1 assignment Exercise 5 - log_perplexity

Hello All

I was working on the " Exercise 5 - log_perplexity" of assignment w1 " Deep N-grams". My code can not pass the unit test:

Here is my code
{moderator edit: code removed}

Just for information, I tried to use .reshape(-1,1) in the denominator ( np.sum(log_p, axis=1) / np.sum(non_pad,axis=1)), but it trigger another error in unit test. Could anyone help me out?

Please do not post your code on the forum. That is not allowed by the Code of Conduct.

If a mentor needs to see your code, they will contact you with instructions.

I’m not a mentor for this course, so I don’t have any suggestions to fix your issue.