C.W.K.
Stream
Lesson 03 of 08 · published

Loss 함수

~8 min · training

Level 0Keras 도제
0 XP0/97 lessons0/20 achievements
0/120 XP to next level120 XP to go0% complete

Loss 매칭이 흔한 첫 버그. binary 분류 → BinaryCrossentropy + sigmoid. multi-class one-hot label → CategoricalCrossentropy + softmax. multi-class integer label → SparseCategoricalCrossentropy + softmax. regression → MSE / MAE / Huber.

activation 과 loss 의 짝 — 같이 가야 해. softmax + categorical_crossentropy 가 표준 짝. 둘이 안 맞으면 학습 안 되거나 NaN. from_logits=True 옵션 쓰면 softmax 빼고 logits 받아 numerical 안정.

Code

# Option A: softmax output + standard loss
model.compile(loss="sparse_categorical_crossentropy")

# Option B (preferred): no output activation + from_logits
model.compile(
    loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True)
)

External links

Exercise

MNIST 두 방식으로 학습 — (a) softmax + sparse_categorical_crossentropy, (b) softmax 없이 + crossentropy(from_logits=True). loss 값과 최종 정확도 비교.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.