C2W4 assignment - problems in create_model()

Hi all, i wonder if anyone can help me understand the issue with my model.

This is my code before i fit the model:

def create_model():

  ### START CODE HERE
  
  # moderator edit: code removed
  
  ### END CODE HERE

  return model

This code resulted in the following error when i tried to fit the model:
Node: ‘sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits’
Received a label value of 24 which is outside the valid range of [0, 24). Label values: 15 10 21 12 1 16 24 3 21 23 17 14 13 17 11 4 10 11 23 5 13 1 17 5 12 8 20 7 12 2 7 14
[[{{node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits}}]] [Op:__inference_train_function_76750]

i then checked my training_labels and their number of unique values. Here’s what i got:
unique_training_labels=[ 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24]
unique_validation_labels=[ 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24]
i noticed that there was no unique label ‘9’, so overall there were 24 unique labels.
Therefore, i should be using 24 in my output layer of the model.

However, the model will work properly only if i put 25 nodes or number_of_classes+1.
Why this is the case? i cannot understand

Hello @Ivan_Trotsenko, Thanks for your post.
Can you please tell me which assignment is that it’s “Device based course” but in week 4 there is only optional assignment and it doesn’t require function for creating a model so can you please make it more clear for me.

Thanks
Jamal

Please don’t post your code on the forum. That’s not allowed by the Code of Conduct.

If a mentor needs to see your code, they’ll contact you with instructions.

Hi Jamal, thanks for getting back to me. I think I accidentally attached my question to the wrong topic.
I was referring to TF developer Certificate - C2 Convolutional Neural Networks - Final Assignment in Week 4

Hello @Ivan_Trotsenko ,

I am a mentor of TensorFlow Developer Professional Certificate Specialization.

Send me your notebook via dm such that I can check where it went wrong. By clicking on the profile picture, you will see an option to message. There you can attach your notebook. Then we can discuss the issues here.

With regards,
Nilosree Sengupta

It’s posted under C2W3. I am shifting it to C2W4 category.

Hello @Ivan_Trotsenko ,

This dataset contains 24 classes.
The alphabets ‘J’ and ‘Z’ are not there.

Your few values for parameters are not right.
As a mentor, I cannot say all parameters specifically. You need to revise, understand and experiment with .

With regards,
Nilosree Sengupta