Categories
Misc

Need some help with my first CNN for a multi-classification task

Hi! I’m building a CNN for the first time for a university project: the idea is to classify images coming from 10 animal classes (taken from ImageNet).

Anybody willing to give me some advice about my model? Here’s my model:

model = Sequential() model.add(layers.InputLayer(input_shape=(224,224,3))) model.add(layers.BatchNormalization()) model.add(layers.Conv2D(64,(3,3), activation='relu')) model.add(layers.BatchNormalization()) model.add(layers.Conv2D(64,(3,3),activation='relu')) model.add(layers.BatchNormalization()) model.add(layers.Conv2D(128,(3,3),activation='relu')) model.add(layers.BatchNormalization()) model.add(layers.Conv2D(256,(3,3),activation='relu')) model.add(layers.AvgPool2D(2,2)) model.add(layers.Flatten(name='features_layer')) model.add(layers.Dense(10, activation='softmax')) 

Training Loss keeps decreasing and training accuracy keeps improving (and even converges to 1) but after ~10 epochs I’m stuck around 0.5 validation accuracy. The actual dataset contains 2500 images, and I tried both with a 0.2 validation split and 0.3. Using 0.2 leads to more stable results, but reach 0.5 val_accuracy more slowly. I can try augmenting my dataset (creating some slightly modified copies of the images I have), but the training time increases quite a lot, and I would like to be reasonably sure that my model is good (at least on theory) before training with high number of epochs and new expanded dataset.

Is the overall structure of my net correct? Some questions:

  • Should the number of convolutional layers and the number of kernel used in each be set ‘by heart’? I’ve seen CNNs with very different architectures when comes to number of Conv2D layers included, and I’m not getting if there’s some heuristics I should follow.
  • Should I use one batch normalization layer at the end of the convolutions, or should I go with a batch normalization after each Conv2D?

Sorry for the bunch of ‘noob’ questions, I hope you’ll understand my perplexity. As I said, it is my first time dealing with building a CNN myself and I feel that even real ‘general’ suggestions might help. I would really appreciate any advice c:

submitted by /u/synchro-azel
[visit reddit] [comments]

Leave a Reply

Your email address will not be published.