3

I have trained a CNN using keras for Image classification with 3 classes. The results are bad and I'm trying to understand what the classifier has learnt and what it has not. It's only giving me an output of 1 class. Is there a way to check which classes the classifier/neural network has been trained with in Keras?

For example a method or an attribute of the classifier that can tell me which classes the network has been exposed to. Is it possible?

This is my network

classifier = Sequential()
classifier.add(Conv2D(64, (5, 5), input_shape  = (256, 256, 3), activation='relu'))
classifier.add(Conv2D(64, (5, 5), activation = 'sigmoid'))
classifier.add(MaxPooling2D(pool_size = (3,3)))
classifier.add(Dense(units = 128, activation = 'relu'))
classifier.add(Dense(units = 3, activation = 'softmax'))
classifier.compile(optimizer = 'adam', loss = 'categorical_crossentropy', metrics = ['accuracy'])

I have used two activations 'relu' and 'sigmoid' for experimental purposes. I'm thinking of only using sigmoid and softmax for the last layer.

Mohit Motwani
  • 4,662
  • 3
  • 17
  • 45

1 Answers1

2

I think your network is not deep enough. I would also suggest to use only relu activation except your last layer where softmax should be used.

I am not sure what you mean by "which classes the network has been exposed to". It has been exposed to the classes of your training data. If you have used a generator, you can obtan class names from numbers with:

label_map = (generator.class_indices)

see more about this here

Ioannis Nasios
  • 8,292
  • 4
  • 33
  • 55