Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

how to get class weights while using keras imagedatagenerator

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()}                     
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #class #weights #keras #imagedatagenerator
ADD COMMENT
Topic
Name
5+8 =