TF2 Course 2 Week 4 error in

Can someone help in to resolve this error?

Please fix the loss function keeping in mind that classes are not one-hot encoded but are integers in range [0, #classes - 1]

I added lines below in the train_val_generators method to solve this error but it causes some minus points.

  training_labels = tf.keras.utils.to_categorical(training_labels, num_classes=26)
  validation_labels = tf.keras.utils.to_categorical(validation_labels, num_classes=26)

What do you mean by ?

If you do this, you cannot get a perfect score on the assignment.

Please click my name and message your notebook as an attachment.

1 Like

There’s no need to convert labels to one-hot version inside train_val_generators. This is because, there’s a variation of the loss function you’ve used that accounts for integer representation of the labels. It looks like sp****_<your loss function>

Thanks, I found sparse_** after my submission but the loss function has never been explained in the courses anyway.

Have you seen this lab?

I saw but I didn’t notice. Thanks.