Hello,
I was able to solve C2W4_Assignment.ipynb, but the model is not what is expected by the verification.
The assignment is to classify 28x28 images of hands depicting the 26 letters of the english alphabet. The last layer of your model should have a number of units that corresponds to the number of possible categories, as well as the correct activation function.
I assume that this means the model had to output a Dense layer with 26 units:
[snippet deleted by mentor]
However this model had an error when the following step tried to fit:
history = model.fit(train_generator,
epochs=15,
validation_data=validation_generator)
=> ValueError: Shapes (None, 1) and (None, 26) are incompatible
I was able to solve this by converting the labels to one-hot values:
[snippet deleted by mentor]
I was able to train my model this way, but the grading also gave the same error as above.
I assume the grading expects an output of 1 unit and not 26?
But this seems to contradict the requirement “The last layer of your model should have a number of units that corresponds to the number of possible categories”
If you one-hot encoded the validation labels the same way you encoded the training labels, please click my name and message your notebook as an attachment.
I sent you the notebook.
I was able to train my model with good accuracy, but it was the grading process that had the error.
The grade was still over 80%, so it’s not a big deal, I’m just wondering if I did something wrong.
I think I found the issue, I had the same problem in another assignment.
The loss function has to be [snippet deleted by mentor].
Your implementation is correct since:
- The number of output units is equal to the number of classes you want to classify.
- Labels are one-hot encoded and so using the non-sparse version of the loss function is valid.
For now, please don’t one-hot encode labels and use the sparse version of the loss function.
The staff have been informed to look into this. Thanks.
Please move this topic to the right subcategory. Here’s the community user guide to get started.
I encountered the same problem as Benny_Segers. The hint of using the sparse version was helpful in getting things to work but it would be more helpful if there was an explanation of when to use the sparse version instead of the non-sparse version. If that topic is covered in another course, then it would be helpful if the course description would indicate that course as a requirement before taking the Convolutional Neural Network series of courses.
Please refer the community user guide
here and create a new topic.
It’s best to make this small effort so that it’s easier to for other learners to find resources via search.