Q:

How to get high accuracy in CNNs?

ML and Data Science world.
I am a newbie to CNNs, but do possess a basic understanding of ML and Neural Networks.
I wanted to create my own CNN that works on the Cats and Dogs Dataset. I preprocessed the data and built my network, but when I fit the model with the data, I am not able to get more than 55% accuracy, which means the model isn't learning anything.
Can anybody explain what I am doing wrong here?
model = Sequential()
model.add(Conv2D(filters=32, kernel_size=(3,3),padding='SAME', input_shape=X[0].shape))

model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2,2), dim_ordering='th'))

model.add(Conv2D(filters=64, kernel_size=(3,3), padding='SAME'))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2,2), dim_ordering='th'))
model.add(Dropout(rate=0.4))

model.add(Conv2D(filters=128, kernel_size=(3,3), padding='SAME'))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2,2), dim_ordering='th'))
model.add(Dropout(rate=0.35))

#model.add(Conv2D(filters=64, kernel_size=(3,3), padding='SAME'))
#model.add(Activation('relu'))
#model.add(MaxPooling2D(pool_size=(2,2), dim_ordering='th'))

model.add(Flatten())
model.add(Dense(1024))
model.add(Activation('relu'))
model.add(Dropout(rate=0.3))

model.add(Dense(2))
model.add(Activation('softmax'))

And this is the optimizer part:
opt = keras.optimizers.SGD(lr=0.0001, decay=0.0)
model.compile(optimizer=opt, loss='binary_crossentropy', metrics['accuracy'])
print(model.summary())

model.fit(X, np.array(Y), validation_data=(test_x, np.array(test_y)), epochs=30, verbose=2)

I've been stuck on this for the past 2 days.
Any and all help is appreciated.
Thanks.

A:

Adding multiple layers before pooling will increase the feature extraction, softmax function is used when there are more than 2 categories/classes, try with sigmoid fuction,
Also, Data Augmentation will help you with tuning hyper-parameters(tilt, width-shift, shear, rotation etc). Go through the documentation.
Give a try with this code, If RMSprop yieds less accuracy try adam,
model = Sequential()
model.add(Conv2D(32, 3, 3, border_mode='same', input_shape=input_shape, activation='relu'))
model.add(Conv2D(32, 3, 3, border_mode='same', activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, 3, 3, border_mode='same', activation='relu'))
model.add(Conv2D(64, 3, 3, border_mode='same', activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(128, 3, 3, border_mode='same', activation='relu'))
model.add(Conv2D(128, 3, 3, border_mode='same', activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(256, 3, 3, border_mode='same', activation='relu'))
model.add(Conv2D(256, 3, 3, border_mode='same', activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten())
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1))
model.add(Activation('sigmoid'))    
model.compile(loss='binary_crossentropy',optimizer=RMSprop(lr=0.0001),metrics=['accuracy'])

