728x90
    
    
  반응형
    
    
    
  SMALL
    ImageDataGenerator class weight

딥러닝시 이미지 데이터의 불균형 문제를 해결하기 위해 class에 따른 가중치를 다르게 부여할 수 있다.
from sklearn.utils import compute_class_weight
import numpy as np
train_classes = train_generator.classes
class_weights = compute_class_weight(
                                        class_weight = "balanced",
                                        classes = np.unique(train_classes),
                                        y = train_classes                                                    
                                    )
                                    
class_weights = dict(zip(np.unique(train_classes), class_weights))
model.fit_generator(..., class_weight=train_class_weights)
balancing an imbalanced dataset with keras image generator - Stack Overflow
balancing an imbalanced dataset with keras image generator
The keras ImageDataGenerator can be used to "Generate batches of tensor image data with real-time data augmentation" The tutorial here demonstrates how a small but balanced dataset can be augme...
stackoverflow.com
728x90
    
    
  반응형
    
    
    
  LIST
    'Python Library > Keras' 카테고리의 다른 글
| [Keras] 멀티모달 함의 분류 (2) (0) | 2024.04.02 | 
|---|---|
| [Keras] 멀티모달 함의 분류 (1) (0) | 2024.03.30 | 
| [Keras] tflite 변환 (0) | 2022.11.24 | 
| [Keras] ImageDataGenerator (0) | 2022.08.20 | 
| [Keras] 배치 정규화 (Batch Normalization) (0) | 2022.07.31 |