# Predictions of a Deep Learning Model

I’ve built a model that classifies digits from 0-9. My dataset is tf.keras.datasets.mnist. I use softmax as the activation function for the output layer.

Q1:

The output layer should consist of 10 neurons. Each representing a digit from 0-9. But even when I change the number of output layer neurons to 20, the predictions are accurate. Seems as if even though I only need to predict 10 digits, I can have more than 10 neurons in the output layer. Why’s that?

Q2:

Also, the prediction is a list of lists right. Each list containing probabilities corresponding to 10 neurons and we take the neuron having the highest probability. My question is, suppose the 6th neuron has the highest probability, how do I know what digit(label) is assigned to it?

I’m a complete newbie to deep learning, so please dumb it down for me.

• I am not exactly sure what you mean in your first question. For your second question, the order of the outputs is the same as the order of the data in your training dataset. I.e. if you trained your model on training data with digits 0 through 9 in that order, the predictions will also have 0 at the first index, 1 at the second index, etc. – Oxbowerce Apr 5 '20 at 19:50

Q1: I do not really understand how the situation in your Q1 is possible - I would expect an error to be thrown about as a mismatch in shape. For example, when I change the number of classes in the final dense layer, I do indeed get an error.

model = Sequential()
activation='relu',
input_shape=input_shape))
# adjust the number of layers from 10 to 20 - which throws an error

ValueError: A target array with shape (60000, 10) was passed for an output of shape (None, 20) while using as loss categorical_crossentropy. This loss expects targets to have the same shape as the output.