how to balance minibatches on keras when training a convolutional neural network?

525 Views Asked by At

I am training a convolutional neural network on images (with size 299, 299, 3). The images can have labels: 0, 1 or 2 (multiclass classification), and the 3 classes are very unbalanced. To improve the training phase I want to make sure that each minibatch contains all three classes. How can I do this?

I am using flow_from_dataframe to pass the images to the neural network.

train_generator=datagen.flow_from_dataframe(
dataframe=train, 
directory=None, 
x_col="directory",
y_col="label",
batch_size=64, 
seed=42, 
shuffle=False, 
class_mode='categorical',
target_size=(299,299))
0

There are 0 best solutions below