I'm working on a CNN model (implemented by keras) that detects landmarks from images. Every landmark (for example Acropolis, Big Ben, Eiffel Tower etc) is as a separate class and is divided into own directory. The training dataset contains 1600 images, validation 400 images and test 500 images. The training process has 80 iterations.
I noticed that with two or three classes the accuracy is quite good (3 classes => accuracy: 0.8353) but by every next class it's getting to decrease.
Is it so that adding more classes increases features and complexity? What could be the solution for that? Adding more layers or data? I have tried to add more layers but it's rather worsened the result than made it better. Is it because of vanishing gradient? Adding more data is big problem because I just can't find more unique images. I also changed other config parameters (optimization algorithm, dropout rate etc) but with no result.
The used config parameters are:
NUMBER_OF_CLASSES = 4
BATCH_SIZE = 32
EPOCHS = 80
DROPOUT_RATE = 0.3
LOSS = 'categorical_crossentropy'
OPTIMIZER = 'rmsprop'
METRICS = ['accuracy']
CLASS_MODE = 'categorical'
And constructed model:
model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3), input_shape=input_shape))
model.add(Activation('relu'))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(2, 2), strides=2))
model.add(Conv2D(64, kernel_size=(3, 3),))
model.add(Activation('relu'))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(2, 2), strides=2))
model.add(Conv2D(128, kernel_size=(3, 3),))
model.add(Activation('relu'))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(2, 2), strides=2))
model.add(Conv2D(256, kernel_size=(3, 3),))
model.add(Activation('relu'))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(2, 2), strides=2))
model.add(Flatten())
model.add(Dense(256))
model.add(Activation('relu'))
model.add(BatchNormalization())
model.add(Dropout(0.3))
model.add(Dense(256))
model.add(Activation('relu'))
model.add(BatchNormalization())
model.add(Dropout(0.3))
model.add(Dense(NUMBER_OF_CLASSES))
model.add(Activation('softmax'))
--------------
Total params: 721,604
Trainable params: 719,620
Non-trainable params: 1,984