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

model.compile()

~8 min · training

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

compile + fit + callback. 세 줄 뒤에 state machine, optimizer step, loss reduction, metrics accumulator, callback bus 다 숨어있어. fit() 이 이상한 짓 할 때 *어느 손잡이* 가 풀렸는지 정확히 알게 해주는 unpack 트랙.

compile 은 학습 *환경 설정*. optimizer (gradient 적용 방법), loss (목표 함수), metrics (모니터링용 지표). 이 셋이 model 에 박혀서 fit 시 쓰여.

호출 형태: model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy']). 문자열로 넘기면 default 인스턴스, 또는 optimizer=keras.optimizers.Adam(learning_rate=1e-4) 같이 인스턴스로 넘겨 hyperparameter 조절.

Code

model.compile(
    optimizer="adam",                            # or keras.optimizers.Adam(1e-3)
    loss="sparse_categorical_crossentropy",      # or Loss instance
    metrics=["accuracy"],                        # list of metric names/instances
)

# For regression:
model.compile(
    optimizer=keras.optimizers.Adam(learning_rate=1e-3),
    loss="mse",
    metrics=["mae"],
)

External links

Exercise

같은 MNIST 모델을 두 방식으로 compile — optimizer='adam' / keras.optimizers.Adam(learning_rate=1e-3). 둘 다 5 epoch 학습, curve 동일한지 확인.

Progress

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

댓글 0

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

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