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

Weight 만 저장 / 로드

~8 min · serialize

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

model.save_weights('weights.weights.h5') + model.load_weights('weights.weights.h5'). architecture 안 저장하고 weight 만. 로드 시 architecture 는 코드에서 다시 빌드해야 함.

유용 시나리오: (1) 학습 도중 checkpoint, (2) 동일 architecture 의 다른 instance 에 weight 적용 (transfer 또는 ensemble), (3) 큰 모델의 일부 layer 만 저장 (예: backbone 만, head 제외).

Code

# Save weights
model.save_weights("weights.weights.h5")

# Load weights into an identical architecture
new_model = build_model()  # Must match original architecture
new_model.load_weights("weights.weights.h5")

# Weight sharding for large models (Keras 3.10+)
model.save_weights("large_model.weights.h5", max_shard_size="2GB")

External links

Exercise

model 10 epoch 학습. ModelCheckpoint 으로 매 2 epoch weight 저장. 학습 후 epoch 6 weight 를 같은 architecture 의 새 instance 에 로드. epoch 6 에 logged 된 accuracy 와 일치 확인.

Progress

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

댓글 0

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

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