Concept | Optimization of image classification models#

Although image classification models are pre-trained, you can change some parameters to fine-tune the models. These settings can affect a model’s memory usage and accuracy.

Batches and epochs#

Image classification models run in cycles called epochs. In one epoch, the model views each image one time. Because models are typically fed thousands of images, viewing all images at once could overload memory capacity. To avoid this, the model breaks each epoch down into batches.

In Dataiku, the default Batch size is 32 images and the default Number of epochs is 50. This means the model will run through each image 50 times, in batches of 32 images at a time.

But often the model does not need all 50 epochs to reach its maximum performance. You can set early stopping so that the model stops running when it detects it has reached its maximum accuracy. Dataiku highly recommends using early stopping.

Image classification models cycle through images in smaller batches, and one full cycle through the images is an epoch.

Data augmentation#

Another way to optimize image classification models is to randomly diversify the image input so the model can better generalize when it sees new images. This is known as data augmentation.

In Dataiku, you can choose for images to be colored, rotated, flipped vertically or horizontally, or cropped. View or change these settings under Design > Basic > Data augmentation.

Using data augmentation to alter images can improve image classification models.

Other strategies#

There are many other ways to optimize image classification models either for speed or performance. Here are a few examples:

  • Choose a different pre-trained network optimized for efficiency or performance.

  • Increase the number of images to train the model, especially for classes that are challenging for the model.

  • Increase the number of layers the model will fine-tune.