📜  如何在使用 keras imagedatagenerator 时获取类权重 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:23.303000             🧑  作者: Mango

代码示例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()}