Check out example codes for "how to get class weights while using keras imagedatagenerator". It will help you in understanding the concepts better.

Code Example 1

from collections import Counter
train_datagen = ImageDataGenerator()
train_generator = train_datagen.flow_from_directory(...)

counter = Counter(train_generator.classes)                          
max_val = float(max(counter.values()))       
class_weights = {class_id : max_val/num_images for class_id, num_images in counter.items()}

Learn ReactJs, React Native from akashmittal.com