
v1 힌지 손실 은 이진 (). Multi-class SVM 으로 확장 (Weston-Watkins 1998):
전체 배치:
N = len(y)
correct = scores[np.arange(N), y][:, None] # (N, 1)
margins = np.maximum(0, scores - correct + 1) # (N, K)
margins[np.arange(N), y] = 0 # 정답 클래스 제외
return margins.sum(axis=1).mean()
함수 multiclass_hinge(scores, y) 를 완성하세요.
scores shape (N, K), y shape (N,) 정수 in [0, K).float (배치 평균).| # | 이름 | 검증 |
|---|---|---|
| 1 | float 반환 | |
| 2 | 완벽 분리 (정답 점수 >> 오답) → ~0 | |
| 3 | 정답 클래스는 손실에 포함 안 됨 | |
| 4 | K=2 특수 케이스 | |
| 5 | margin 안에 있는 오답 → 페널티 | |
| 6 | 손계산 toy | |
| 7 | 루프 금지 |
코드를 작성하고 Run 을 눌러보세요.