I am doing the C3W2 assignment and having problem with exercise 5. When I run the test i get “Your model is not compatible with the dataset you defined earlier. Check that the loss function and last layer are compatible with one another.”
Honestly, I don’t know what I have to change from here…
Please see the screenshot.
Screenshot removed as it contained grade cell codes which assess your assignment grade. posting codes or link to graded assignment is violation of code of conduct and against community guidelines
because your last dense layer output unit is 5 with activation softmax, loss of categorical_crossentropy is an incorrect choice. you need to use “sparse_categorical_crossentropy”
please don’t post grade cell codes as it is against community guidelines.
2 Likes
Thank you. I didn’t know that part. Will take into consideration next time 
It’s not the 5 units of the output that matters, is it? I thought the real question is how the labels are encoded. If they are “one hot” then you need “categorical” loss, but if they are in categorical form (one integer with values from 0 to 4), then you need the “sparse” cross entropy function.
But I am not a mentor for this course and have not done this assignment, so I’m not familiar with the full details here.
yes precisely the class features, thanks @paulinpaloalto
I hoped he understood when he used unit of 5 for the last dense layer unit as he knew that class features based on labels codes from previous grade cell.
1 Like