I ran into this error when I used this code
ValueError: `labels.shape` must equal `logits.shape` except for the last dimension. Received: labels.shape=(2,) and logits.shape=(1, 2)
Its not nice posting your code here. The label shape and logits (predictions) are of not the same shape. The problem has arisen in your calculation of the expected_output. Reconsider that line calculation.
I’ve tried everything and nothing seems to work. Could you please provide the correction I need to make? I’m out of depth
Look at the example in Ungraded Lab 3: Saliency in the “Compute Gradients” section, and also in the “Saliency” lecture video to see how they calculate expected_output there.
As a test, you can temporarily add some print statements in your code to print the shape of expected_output as you’ve calculated it compared with how it would look if you used the approach shown in these examples. You might also want to temporarily print expected_output itself to get a sense of what that looks like with both implementations.