I have transposed both labels and logits so both have the shape (6,2) and passed them to cross entropy function and then to reduce_sum function.
But it returns the value: tf.Tensor(1.6142862, shape=(), dtype=float32)
Can you give me some insight on what my mistake is?
I’m dealing with that problem, too. I’ve transposed logits and labels (tf.transpose(logits), tf.transpose(labels). And also used tf.keras.losses.categorical_crossentropy and tf.reduce_sum, from_logits=True.
I’ve read all the threads about this exercise and still don’t know what the problem is. Everytime I get this error: ValueError: Shapes (2, 4) and (2, 6) are incompatible.
One important point to note here is that order of logits and labels is also important when passing them to the categorical_crossentropy. Labels comes first, then logits.
Thanks for your guidance. I replaced them (tf.transpose(labels), tf.transpose(logits), from_logits=True), and still get the same error.
No, I didn’t make any changes. I also got a fresh copy of the assignment (according to instructions) to make sure the code and assignments have not changed.
So, to update others, Niloofar_Hamidi didn’t pass the previous test which lead to an error in this test too. Remember that you have to pass all the previous tests before proceeding to the next one.
Hello @ricky_pii! Thank you for sending me your code.
I suggest reading Kin’s message carefully. It says, have “you set the 3rd parameter, from_logits= True”? True, I repeat, True. Its True, not False.