C.W.K.
Stream
Lesson 02 of 07 · published

Mixed precision 학습

~8 min · advanced

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

Tensor Core (V100, A100, H100, RTX 30/40 시리즈) 가 FP16 / BF16 에서 2-3 배 더 빠른 matmul. mixed precision 은 weight / activation 을 FP16 로, master copy 와 일부 통계는 FP32 로 — 속도 + 정확도 둘 다.

Keras 에서 한 줄: keras.mixed_precision.set_global_policy('mixed_float16'). 그 후 model 학습. loss scaling 자동 — FP16 underflow 방지. 큰 모델·큰 배치에서 가장 효과적.

백엔드 노트:
⚙️ Backend Note

Code

# Enable mixed precision globally
keras.mixed_precision.set_global_policy("mixed_float16")

# Build and train normally — Keras handles the casting
model = keras.Sequential([
    keras.Input(shape=(784,)),
    layers.Dense(256, activation="relu"),  # Computes in float16
    layers.Dense(10),                        # Raw logits (no activation)
])

# Use from_logits for numerical stability with mixed precision
model.compile(
    optimizer="adam",
    loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
)

External links

Exercise

CIFAR-10 을 mixed_float16 유/무 학습. epoch time (~30-50% 감소 예상) + 최종 accuracy (~0.5% 이내) 비교.

Progress

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

댓글 0

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

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