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

Quantization

~8 min · advanced

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

FP32 weight 를 INT8 로 표현 — 모델 크기 4 배 ↓, latency 2-4 배 ↓. accuracy 손실은 보통 < 1% (잘 튜닝하면). edge / mobile / serverless 처럼 latency / cost-critical 환경에 핵심.

두 방식: (1) post-training quantization (PTQ) — 학습 후 weight 만 변환, 빠르고 쉬움. (2) quantization-aware training (QAT) — 학습 시 INT8 시뮬, accuracy 손실 ↓. PTQ 로 시작, accuracy 부족할 때만 QAT.

Code

# Int8 quantization (4x smaller, faster inference)
model.quantize("int8")

# Int4 quantization (8x smaller, Keras 3.11+)
model.quantize("int4")

# Selective quantization (exclude specific layers)
model.quantize("int8", type_filter=["Dense"])  # Only Dense layers

External links

Exercise

MNIST 학습. default float32 + INT8 PTQ (representative_dataset 사용) 두 TFLite 로 변환. 파일 크기 + inference latency 비교.

Progress

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

댓글 0

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

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