CNN: challenge to recognize simple blocks

Viewed 62

I would love to obtain insights and perspectives on the following challenge. I am trying to train a CNN to classify images that have a distinct "block" in a different color (please see the example below). The images are 2D arrays (e.g. 20 by 100 pixels) where white is coded as 0, blue is coded as 1 and green as 2.

I am struggling - somewhat to my surprise - to train a network with good performance on these type of images - especially to prevent over-fitting and very poor performance on validation sets when image sizes are getting bigger (e.g. 40 by 100). I am trying to understand / conceptualize what type of CNN structure is needed to recognize these type of features.

I have included my current network structure below - but this structure tends to have mixed performance, and fails or gets very slow when image sizes increases. I presume that the network has to see the entire cyan 'block' from top to bottom to make an accurate classification.

I would love to get thoughts on the best approach to do so. Is the best approach to add more layers to the network? Or work with bigger convolution windows? Or to add more conv. filters to each layer (e.g. from 64 to 96, etc.)? I feel I am doing something wrong on a basic level.

Thoughts and perspectives much appreciated.

model = Sequential()
model.add(Conv2D(64, (3, 3), input_shape=input_shape))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))

model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))

model.add(Flatten())
model.add(Dropout(0.25))
model.add(Dense(1,activation="sigmoid"))  

opt = keras.optimizers.rmsprop(lr=0.001, decay=1e-5)
model.compile(loss='binary_crossentropy',optimizer=opt,metrics=['accuracy'])

enter image description here

1 Answers
Related