user10761064
user10761064

Reputation:

How to increase accuracy in Convolutional neural network

I am implementing flower recognition - the dataset has few types of flowers. Totally the dataset contains about 4000 images

My code -

model = Sequential()

model.add(Conv2D(32, (3, 3), padding='same', input_shape=(32, 32, 3), activation="relu"))
model.add(Conv2D(32, (3, 3), activation="relu"))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.5))

model.add(Conv2D(64, (3, 3), padding='same', activation="relu"))
model.add(Conv2D(64, (3, 3), activation="relu"))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))

model.add(Flatten())
model.add(Dense(512, activation="relu"))
model.add(Dropout(0.5))
model.add(Dense(5, activation="softmax"))

model.compile(loss='categorical_crossentropy',optimizer='adam',metrics=['accuracy'])
history=model.fit(x_train,y_train,batch_size=64,epochs=7,validation_data=(x_test, y_test),shuffle=True)

From this, I get the accuracy and loss

Accuracy scale

Loss scale

Then, I need more accuracy. So, I just increase the epochs=30 and the results are

(FOR epochs = 30)

Accuracy scale

Loss scale

I understand that neural network set random weights so that we get different results. But how can I improve the accuracy. I am new to neural nets. Would greatly appreciate some explanation. Thank you

Upvotes: 0

Views: 2576

Answers (2)

Berkay Berabi
Berkay Berabi

Reputation: 2348

I think that you have enough data samples. I recommend you to try the following:

  1. Remove the activation from convolutional layers.
  2. After each convolutional layer, apply BatchNormazalization
  3. After each batch normalization, now apply activation e.g Relu

You can also try to increase number of kernels in convolutional layers and reducing the batch size, maybe 32 or 16

Upvotes: 0

According to the training and validation metrics, the model seem to have over fitted. That is why training accuracy is increasing while validation accuracy seems constant. The reason for over-fitting is the lack of training samples. You may have to increase the number of training samples. Try followings one by one.

  • Reduce the dropout rate to ~0.2.
  • Try reducing number of convolution layers

Please update a link to data-set if you want us to try a model with that.

Upvotes: 1

Related Questions