목록Python (45)
잡동사니 블로그
ImageFolder는 PyTorch의 torchvision.datasets 모듈에 속한 클래스로, 이미지 데이터를 폴더 구조에 기반해 자동으로 라벨을 할당하고 데이터셋을 생성해주는 클래스 import torchfrom torchvision import datasets, transformsfrom torch.utils.data import DataLoader, random_splitimport matplotlib.pyplot as plt#Image PreProcessingtransform = transforms.Compose([ transforms.Resize((256, 256)), transforms.Grayscale(num_output_channels=1), transforms.To..
Tkinter Tkinter는 파이썬의 표준 GUI (그래픽 사용자 인터페이스) 라이브러리로, 파이썬에서 간단한 GUI 애플리케이션을 만들기 위해 사용. Pyinstaller PyInstaller는 Python 애플리케이션과 모든 종속성을 단일 패키지로 묶음.그리하여 사용자는 Python 인터프리터나 모듈을 설치하지 않고도 패키지된 앱을 실행할 수 있음. PyInstaller는 Python 3.8 이상을 지원하며 numpy, matplotlib, PyQt, wxPython 등과 같은 많은 주요 Python 패키지를 올바르게 번들로 제공함. https://pyinstaller.org/en/stable/ PyInstaller Manual — PyInstaller 6.5.0 documentation PyIns..
Class imbalance? 주로 분류(classification)에서 다수의 데이터와 소수의 데이터 차이 예를 들어 위와같은 데이터로 모델을 만든다고 가정할 때 모델이 불균형한 클래스에 대해 편향되도록 학습됨. 모든 데이터를 0으로 학습하더라도 95%의 Accuracy를 가진 모델이 됨. 이를 해결하기 위해 Over Sampling, Under Sampling이 있지만, Class weight라는 방법도 있다. \[ \text{LogLoss} = - \frac{1}{N} \sum_{i=1}^{N} \left[ y_i \log(\hat{y}_i) + (1 - y_i) \log(1 - \hat{y}_i) \right] \] 여기서 Class weight인 - \( w_{0} \)와 - \( w_{1} \..
위 이미지가 너무 잘 설명되어있어서... Multi-class -> 여러개의 label중 하나 Multi-label -> 여러개의 label중 여러개 신기하게도 tensorflow와 다르게 output에 따로 function을 안취하고 loss function내에 자체적으로 계산되는 형식. 심지어 공식문서에서도 강조되어 있음. # Multi-class # CrossEntropyLoss 사용 output = torch.tensor([[1,0,0], [0,0,2]]) # 모델의 출력값 target = torch.tensor([0, 2]) # 실제 레이블 criterion = nn.CrossEntropyLoss() #input float, output long loss = criterion(output.flo..