How to give class_weight for 3D data in fit_generator?

Viewed 207

I need to do a semantic segmentation task on pavement images. I have an imbalanced dataset. I am using a generator with the batch size of 5 (due to the limited memory) to pass the data to fit_generator to fit the model on my large dataset. I am trying to use class_weight, but it gives me the error:

ValueError: class_weight not supported for 3+ dimensional targets.

I read that sample_weight is used for 3D data (I do not exactly know how it works). However, fit_generator does not have this argument (sample_weight). Can anyone help me with this problem?

My training dataset contains 41000 images with the size of (512,512) and 12 labels. My generator yields images with the dimension of (batch_size, 512, 512, 1) and labels with the dimension of (batch_size, 512, 512, 12).

autoencoder.fit_generator(train_gen,
                          epochs= 200,
                          steps_per_epoch = NO_OF_TRAINING_IMAGES//BATCH_SIZE,
                          shuffle= True,
                          validation_data= val_gen,
                          validation_steps= NO_OF_VAL_IMAGES//BATCH_SIZE,
                          callbacks= callbacks_list,
                          class_weight= class_weight,
                          use_multiprocessing=True,
                          workers=8)
0 Answers
Related