이미지 분류기 학습

PyTorch로 배우는 Intermediate Deep Learning

Michal Oleszak

Machine Learning Engineer

데이터 증강 다시 보기

고양이 이미지.

PyTorch로 배우는 Intermediate Deep Learning

데이터 증강 다시 보기

수평 뒤집고 회전한 고양이 이미지.

PyTorch로 배우는 Intermediate Deep Learning

증강하면 안 되는 것

노란 레몬과 초록 라임은 모양이 같고 색만 다름.

PyTorch로 배우는 Intermediate Deep Learning

증강하면 안 되는 것

노란 레몬과 초록 라임은 모양이 같고 색만 다름.

PyTorch로 배우는 Intermediate Deep Learning

증강하면 안 되는 것

세로로 뒤집은 "W"가 "M"처럼 보임.

  • 증강은 레이블에 영향을 줄 수 있음
  • 혼란 여부는 과제에 따라 달라짐
  • 데이터와 과제를 고려해 증강을 선택하십시오!
PyTorch로 배우는 Intermediate Deep Learning

구름 분류용 증강

구름 사진 샘플.

  • 무작위 회전: 다양한 구름 각도에 노출
  • 수평 뒤집기: 하늘의 다른 시점을 모사
  • 자동 대비 조정: 다른 조명 조건을 모사
train_transforms = transforms.Compose([
    transforms.RandomHorizontalFlip(),
    transforms.RandomRotation(45),
    transforms.RandomAutocontrast(),
    transforms.ToTensor(),
    transforms.Resize((128, 128))
])
PyTorch로 배우는 Intermediate Deep Learning

Cross-Entropy 손실

  • 이진 분류: BCE(loss) 사용
  • 다중 클래스 분류: cross-entropy loss
  • criterion = nn.CrossEntropyLoss()
PyTorch로 배우는 Intermediate Deep Learning

이미지 분류기 학습 루프

net = Net(num_classes=7)

criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(net.parameters(), lr=0.001)


for epoch in range(10): for images, labels in dataloader_train: optimizer.zero_grad() outputs = net(images) loss = criterion(outputs, labels) loss.backward() optimizer.step()
PyTorch로 배우는 Intermediate Deep Learning

연습해 봅시다!

PyTorch로 배우는 Intermediate Deep Learning

Preparing Video For Download...