Keras: model accuracy drops after reaching 99 percent accuracy and 0.01 loss

I am using the adapted LeNet model in keras to do the binary classification. I have about 250,000 training samples at a 60/40 ratio. My model trains very well. In the first epoch, the accuracy reaches 97 percent with a loss of 0.07. After 10 epochs, the accuracy is over 99 percent with a loss of 0.01. I am using CheckPointer to save my models as they improve.

Around the 11th era, the accuracy drops to about 55 percent with a loss of about 6. How is this possible? Is it because the model couldn't be more accurate and tries to find the best weights, but completely can't?

My model is an adaptation of the LeNet model:

lenet_model = models.Sequential()
lenet_model.add(Convolution2D(filters=filt_size, kernel_size=(kern_size, kern_size), padding='valid',\
                        input_shape=input_shape))
lenet_model.add(Activation('relu'))
lenet_model.add(BatchNormalization())
lenet_model.add(MaxPooling2D(pool_size=(maxpool_size, maxpool_size)))
lenet_model.add(Convolution2D(filters=64, kernel_size=(kern_size, kern_size), padding='valid'))
lenet_model.add(Activation('relu'))
lenet_model.add(BatchNormalization())
lenet_model.add(MaxPooling2D(pool_size=(maxpool_size, maxpool_size)))
lenet_model.add(Convolution2D(filters=128, kernel_size=(kern_size, kern_size), padding='valid'))
lenet_model.add(Activation('relu'))
lenet_model.add(BatchNormalization())
lenet_model.add(MaxPooling2D(pool_size=(maxpool_size, maxpool_size)))
lenet_model.add(Flatten())
lenet_model.add(Dense(1024, kernel_initializer='uniform'))
lenet_model.add(Activation('relu'))
lenet_model.add(Dense(512, kernel_initializer='uniform'))
lenet_model.add(Activation('relu'))
lenet_model.add(Dropout(0.2))
lenet_model.add(Dense(n_classes, kernel_initializer='uniform'))
lenet_model.add(Activation('softmax'))

lenet_model.compile(loss='binary_crossentropy', optimizer=Adam(), metrics=['accuracy'])

      

+3


source to share


1 answer


The problem was the application of losses binary_crossentropy

, whereas in this case categorical_crossentropy

should be applied. Another approach is to lose binary_crossentropy

, but change the output to dim=1

and activate to sigmoid

. The strange behavior comes from the fact that when binary_crossentropy

multi-class binary classification (with two classes) is actually solved, whereas your task is a binary classification of one class.



+3


source







All Articles