I have used the line:

*{Moderator Edit: Solution Code Removed}*

output : tf.Tensor(0.17102128, shape=(), dtype=float32)

expected output: tf.Tensor(0.810287, shape=(), dtype=float32)

the shapes of labels and logits are the same (6,2) and (6,2). What is wrong with the code?

It is given that:

logits – … of shape **(6, num_examples)** and labels – … **same shape as Z3**

Also given that

“It’s important to note that the “`y_pred`

” and “`y_true`

” inputs of tf.keras.losses.categorical_crossentropy are expected to be of shape (**number of examples, num_classes**).”

The bold parts are the hint for you to solve the error. One more hint: **Transpose**.

PS: I am deleting your code as posting your code is not allowed…