Exercise 4 in lab 1

In exercise 4 lab 1 , it is written that it will give error when we change the last layer number of neurons from 10 to something else, but after some observations , it is giving error only when #neurons<10, but #neurons>=10 it is not giving any error and calculating till the end. please help me to understand this ,

For a multi class classification problem, the number of neurons in the output layer is set to the number of classes.

There’s nothing wrong in setting the number of dense units to a number greater than the available classes in the dataset since the model will learn not to predict them during training. It’s a waste of computation resources to do this though.

Having more dense units than available labels makes sense when there is a hole in the labels and you don’t have the liberty to change the dataset. Please see course 2 week 4 assignment where you’ll need more than 24 units in the output dense layer when the data contains only 24 classes. There is no data for the letters J and Z and skipping one label was preferred rather than adjusting the labels.

The only requirement is that the number of units in the final dense layer should not be less than the number of classes the model is trying to predict.