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

Feature extraction

~8 min · transfer

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

가장 단순한 transfer 방식: backbone 전체 freeze, 위에 classifier head 만 학습. backbone.trainable = False — 모든 weight 가 non-trainable. 그 위에 작은 Dense layer 학습.

이 방식은 학습 빠름, GPU 적게 필요, 작은 dataset 에 안전. 단점은 backbone 의 feature 가 자기 task 에 *완벽 적합* 안 함. 그게 답답하면 다음 단계 — fine-tuning.

Code

# Freeze the pretrained weights
base_model.trainable = False

# Add a custom classification head
inputs = keras.Input(shape=(224, 224, 3))
x = base_model(inputs, training=False)  # Keep BN in inference mode
x = layers.GlobalAveragePooling2D()(x)
x = layers.Dropout(0.2)(x)
outputs = layers.Dense(5, activation="softmax")(x)

model = keras.Model(inputs, outputs)
model.compile(
    optimizer="adam",
    loss="categorical_crossentropy",
    metrics=["accuracy"],
)

# Train only the head (~5-10 epochs)
model.fit(train_ds, epochs=10, validation_data=val_ds)

External links

Exercise

frozen ResNet50 + custom head 로 binary classifier (cat vs dog) 짜. 작은 subset (1000 image) 으로 5 epoch 학습. from-scratch weight 의 같은 architecture 와 비교 — gap 확인.

Progress

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

댓글 0

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

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