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

실전 시나리오: EfficientNetB0 으로 작은 dataset (꽃 / 음식 / 의료 등) 분류. KerasHub 의 from_preset 으로 backbone, GlobalAveragePooling + Dense(num_classes) head. 5 단계 레시피 적용.

구조: backbone = keras_hub.models.EfficientNetBackbone.from_preset('efficientnet_b0_imagenet'); backbone.trainable = False; head 추가; compile + fit. 그 후 backbone.trainable = True; for layer in backbone.layers[:-30]: layer.trainable = False; lr 10× 낮춤; 다시 compile + fit.

Code

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 등). EfficientNetB0 transfer pipeline 빌드. validation accuracy ≥85%. 스크립트를 재사용 가능 transfer-learning 템플릿으로 저장.

Progress

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

댓글 0

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

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