Error in Course 2 Week 3 Exercise 6

Calculating the Loss,
I have tried multiple options to calcualte the loss, but I am getting the error,
I have also tried reshaping it with multiple options.

{moderator edit - solution code removed}

I am not able to understand why test is not gettting passed

{moderator edit - solution code removed}

You are forgetting to tell the cost function that the prediction inputs are “logits”, meaning the linear outputs from the output layer, rather than softmax outputs. Take a look at the documentation for the loss function and have a look at the meaning of the from_logits parameter. Here’s another recent thread which discusses that. It’s been a while since I watched the lectures and I don’t remember of Prof Ng mentions this anywhere, but he consistently handles the outputs this way anytime he is using TF with cross entropy loss functions.

Also note that it’s not a bug, but you’re working way too hard when you do the transposes. Why do you need the reshapes and the casts there? I didn’t do any of that and it did not cause me any problems.