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

Preprocessing layer

~8 min · layers

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

Keras 3 의 강력한 발상 — 전처리도 layer. Rescaling / Normalization / RandomFlip / RandomRotation / TextVectorization. 모델 graph *안에서* 동작 → saved model 에 같이 따라감 → deploy 시 누락 사고 차단.

학습 데이터로 *adapt()* 호출 (TextVectorization 이 vocab 학습, Normalization 이 mean/var 학습) 하면 layer 가 통계 가짐. 그 후 일반 layer 처럼 사용. inference 환경에서도 자동으로 같은 통계 적용.

Code

# Numeric preprocessing
layers.Rescaling(1.0/255)             # Normalize pixel values
layers.Normalization()                  # Standardize features (.adapt() first)

# Text preprocessing
layers.TextVectorization(
    max_tokens=10000,
    output_mode="int",
    output_sequence_length=200,
)

# Category encoding
layers.CategoryEncoding(num_tokens=10)
layers.StringLookup(vocabulary=["cat", "dog", "bird"])

External links

Exercise

Rescaling(1./255) + RandomFlip('horizontal') 을 첫 두 layer 로 가지는 CNN 짜. CIFAR-10 학습. model 저장하고 raw [0,255] pixel 로 predict — rescaling 이 따라가는지 확인.

Progress

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

댓글 0

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

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