Week 3 Exercise 6 compute cost Error please help

Attached is a picture of my code and the error. Could anyone explain to me what is wrong?
I’ve transposed the logits and labels. Set y-true as labels, and y-pred as logits. And did the “from_logits = True” part.

Edit by mentor: Removed the first screenshot.

Hi @sdkyuan,

I think you just got the wrong dimensions for the labels, they should be (2, 6) and not (2, 4).

Check this other post out: Shapes (2, 4) and (2, 6) are incompatible

Also, please don’t show your code in the post. You can always send it as a DM to a mentor or just show the errors, as to not spoil the answer to others :slight_smile:

Thanks and hope that helps!