I need to train a convolutional neural network to classify snake images. The problem is that I have only a small number of images available for some snake types.

So, what is the best approach to train a neural network for image classification using a small data set?


2 Answers 2


Use Fine Tuning

You can simply use a pre-trained model on ImageNet, as this data set has multiple snakes classes.

Then you can fine tune the model with your own small data set and outputs. See this for further understanding : Fine Tuning in Keras

(if you don't use Keras, there are other tutorials on the internet using other Machine Learning framework)

The idea is just removing the last layer (1000 outputs if you use a model pre-trained with ImageNet) and adding a layer of your choice with random weights and a custom number of outputs (number of your classes).

Then your retrain your network, in general we retrained only the last layers (as first layers have more general features).


Besides using transfer learning described in other answer, you should consider using siamese network. This type of network is used in cases when one does not posess many examples of objects he wants to distinguish. General idea is that instead of "telling" the network "This is a cobra", you provide information like: "This is a cobra, and that is a rattlesnake, learn the difference".

There is a whole subject dedicated to your problem and it is called one shot learning.

Take a look at this tutorial: https://hackernoon.com/one-shot-learning-with-siamese-networks-in-pytorch-8ddaab10340e

  • $\begingroup$ This is what I learned on Andrew Ng's Deep Learning course at Coursera, and I recommend the course if the OP wants to learn about it. $\endgroup$
    – Blaszard
    Commented Aug 2, 2018 at 1:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .