NahidEbrahimian
NahidEbrahimian

Reputation: 61

Loss function for binary classification with problem of data imbalance

I try to segment of multiple sclerosis lesions in MR images using deep convolutional neural networks with keras. In this task, each voxel must be classified, either as a lesion voxel or healthy voxel.

The challenge of this task is data imbalance that number of lesion voxels is less than number of healthy voxels and data is extremely imbalanced.

I have a small number of training data and I can not use the sampling techniques. I try to select appropriate loss function to classify voxels in these images.

I tested focal loss, but I could not tuning gamma parameter in this loss function.

Maybe someone help me that how to select appropriate loss function for this task?

Upvotes: 2

Views: 560

Answers (1)

Shai
Shai

Reputation: 114896

Focal loss is indeed a good choice, and it is difficult to tune it to work.

I would recommend using online hard negative mining: At each iteration, after your forward pass, you have loss computed per voxel. Before you compute gradients, sort the "healthy" voxels by their loss (high to low), and set to zero the loss for all healthy voxels apart from the worse k (where k is about 3 times the number of "lesion" voxels in the batch).
This way, gradients will only be estimated for a roughly balanced set.

This video provides a detailed explanation how class imbalance negatively affect training, and how to use online hard negative mining to overcome it.

Upvotes: 2

Related Questions