Colin Brown
Colin Brown

Reputation: 599

Kera's val_acc 99.9% but predictions poor for multi label classification

Updated to include more information and context.

I've spotted other questions similar to this before, but the solutions don't seem to help me. I've got ~1000 labels of font letters and I'm using sigmoid activation to return the probabilities of each label that it is a particular font. The fonts are grayscale and each class has about 60 images in it of varying size on a white background.

I'm using callbacks to prevent overfitting and it's running for 3 epochs and quickly getting to 99.99% val_acc and acc, with 3 epochs, the results look like this in the first epoch (500 steps):

24576/44371 [===============>..............] - ETA: 4480s - loss: 0.0185 - acc: 0.9982]

And at the end after 3 epochs:

44370/44370 [==============================] - 9634s - loss: 0.0177 - acc: 0.9989 - val_loss: 0.0177 - val_acc: 0.9989

The model predictions of the generated model are no where close, the closest being a 10% match of a font letter that looks completely different. Something isn't right, could someone help me out here? Here's the model code:

model = models.Sequential()
model.add(Conv2D(32, (3, 3), input_shape=(150,150,1), activation='relu'))
BatchNormalization(axis=1)
model.add(Flatten())
model.add(Dense(1000, activation='sigmoid'))
model.compile(loss='binary_crossentropy', #categorical_crossentropy
optimizer='adam',
metrics=['accuracy'])

My configuration options are:

Does anyone have any suggestions?

Upvotes: 1

Views: 152

Answers (1)

serv-inc
serv-inc

Reputation: 38147

~1000 labels of font letters [...] each class has about 60 images in it of

so you only have 60 images per class?

Some points come to mind: If you use a ImageDataGenerator, you can increase the amount of input by rotation, shearing, zooming, etc. This increases the input range for the network. And you can set aside a validation_split to keep from training, to only be used in validation.

Upvotes: 1

Related Questions