I am working on an multi-class image classification problem (with 9 classes), i am using a pretrained DenseNet121 (on ImageNet), i'm using Keras.
i am using densenet as a feature extractor, with a single layer as the classifier (with 9 neurons, one for each class).
base_model = DenseNet121(weights="ImageNet", include_avg=True, include_top=False) x = Dropout(0.5)(base_model.output) x = Dense(9, activation="softmax")(x) model = Model(inputs=base_model.input, outputs=x)
By mistake i added a Dropout layer before the classification layer, as far as i understand, this means that, during training, if the model gives a correct prediction, but dropout takes effect, it might give a wrong prediction because the connection between the before layer neurons and the correct neuron is cut, so the model will be penalized, and vice-versa with a wrong prediction (if the next highest probability neuron is the correct class).
But what i got was an increase in accuracy by about 2.3% (from 94.49% to 96.82%), and decreased loss by about 0.02.
My question is, why did i get a better result with the dropout layer?
Thank you very much.