Introduction to tensor flow

I am getting the following error while running the compute_cost function. I am not able to figure out the error message

tf.Tensor(1.2030517999712549, shape=(), dtype=float64)

AssertionError Traceback (most recent call last)
9 print("\033[92mAll test passed")
—> 11 compute_cost_test(compute_cost)

in compute_cost_test(target)
5 print(result)
6 assert(type(result) == EagerTensor), “Use the TensorFlow API”
----> 7 assert (np.abs(result - (0.7752516 + 0.9752516 + 0.7752516) / 3.0) < 1e-7), “Test does not match. Did you get the mean of your cost functions?”
9 print("\033[92mAll test passed")

AssertionError: Test does not match. Did you get the mean of your cost functions?

Hi, @udit_goswami.

I sent you a message a while ago. Were you able to fix this? :slight_smile:

Hi @nramon,
I’m getting the same message. What solution did you suggest above?
Cheers, Harry

Can you please explain what I am doing wrong? I am getting the same error.
Kindly advise.

Solved for @Kiranmayee.

Never hard-code dimensions unless the exercise explicitly tells you to do so.

Good luck with the rest of the specialization :slight_smile:

Hi. I’m having the same issue and I can’t figure out what’s wrong. I use the tf.reduce_mean after using the tf.keras.losses.categorical_crossentropy and the notes say that this cost function expected the logits and labels to be of shape (number of examples, num_classes). The shape is (6,num_examples), so I tried using the tf.transpose on the inputs, but it doesn’t seem to solve the issue. Any other hints?

Fixed by @Catherine_Nguyen.

Take a look at the hints in this topic if you get the same error.

Good luck with the rest of the specialization :slight_smile:

Hey @nramon, I can’t understand your hint. We know, we don’t need to hard code but there is lots of thing going on in computing cost function. Here is a useful thread folks may find helpful.