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

실전 — EfficientNet fine-tuning

~8 min · transfer

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

전부 한 스크립트에

이게 track 전체를 돌릴 수 있는 workflow 하나로 압축한 거야 — 새 image-classification 프로젝트마다 복붙할 그 물건. lesson 6 레시피를 구체화해서 읽어: frozen EfficientNetV2S backbone 로드, 작은 head 부착, head 학습 (phase 1), 그 다음 위쪽 layer unfreeze 하고 1e-5 로 fine-tune (phase 2). 아래 Code section 이 완성된 프로그램이야.

눈여겨볼 head 선택

이 head 는 맨바닥 feature-extraction lesson 보다 한 단계 더 풍부해: GlobalAveragePooling2D 다음에 final classifier 전에 Dense(128, relu) bottleneck 을 하나 끼워. 이 layer 가 내 class 에 맞게 backbone feature 를 재조합할 여유를 주고, Dropout(0.3) 이 작은 data 에서 정직하게 잡아줘. 마지막 Dense(5, softmax) 는 내 class 수에 맞춰 바꾸고, backbone preset 이 다른 해상도를 기대하면 input_shape 도 조정.

이 템플릿에서 실제 프로젝트로

더 키울 때 움직이는 부품은 data pipeline (train_ds / val_ds) 이랑 epoch 두 개뿐이야. 나머지 — freeze/unfreeze 춤, compile 두 번, 100× LR 낮추기 — 는 적힌 그대로 둬. 템플릿 갖는 이유가 이거야: transfer 기계장치가 근육 기억이 되고, 집중은 data 랑 metric 에 써.

Code

end-to-end transfer pipeline (feature extraction + fine-tune)·python
import keras
from keras import layers

# Load pretrained EfficientNetV2S
base = keras.applications.EfficientNetV2S(
    weights="imagenet", include_top=False,
    input_shape=(224, 224, 3),
)
base.trainable = False

# Build model
inputs = keras.Input(shape=(224, 224, 3))
x = base(inputs, training=False)
x = layers.GlobalAveragePooling2D()(x)
x = layers.Dense(128, activation="relu")(x)
x = layers.Dropout(0.3)(x)
outputs = layers.Dense(5, activation="softmax")(x)
model = keras.Model(inputs, outputs)

# Phase 1: Feature extraction
model.compile(optimizer="adam", loss="categorical_crossentropy", metrics=["accuracy"])
model.fit(train_ds, epochs=10, validation_data=val_ds)

# Phase 2: Fine-tuning
base.trainable = True
for layer in base.layers[:-20]:
    layer.trainable = False
model.compile(optimizer=keras.optimizers.Adam(1e-5), loss="categorical_crossentropy", metrics=["accuracy"])
model.fit(train_ds, epochs=20, validation_data=val_ds)

External links

Exercise

공개 dataset 골라 (Oxford Flowers, Food-101 등). 위 EfficientNet transfer pipeline 을 end-to-end 빌드. validation accuracy ≥85%. 스크립트를 재사용 가능 transfer-learning 템플릿으로 저장.

Progress

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

댓글 0

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

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