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

실전 — 전체 학습 파이프라인

~8 min · training

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

End-to-end: data load → preprocessing → model 빌드 → compile → fit (with callbacks) → evaluate → save. CIFAR-10 로 작은 CNN 학습 + 모든 best practice 한 번에. 이 패턴이 production training script 의 뼈대.

구조: (x_train, y_train), (x_test, y_test) = keras.datasets.cifar10.load_data(); data augmentation pipeline; model 빌드; compile (Adam + sparse_crossentropy + accuracy); callbacks list (4 종); fit (validation_split=0.1); evaluate on test; model.save('cifar10.keras').

Code

import keras
from keras import layers

# Build model
model = keras.Sequential([
    keras.Input(shape=(784,)),
    layers.Dense(256, activation="relu"),
    layers.Dropout(0.3),
    layers.Dense(128, activation="relu"),
    layers.Dropout(0.2),
    layers.Dense(10, activation="softmax"),
])

# Compile
model.compile(
    optimizer=keras.optimizers.Adam(1e-3),
    loss="sparse_categorical_crossentropy",
    metrics=["accuracy"],
)

# Callbacks
callbacks = [
    keras.callbacks.EarlyStopping(
        monitor="val_loss", patience=5,
        restore_best_weights=True,
    ),
    keras.callbacks.ModelCheckpoint(
        "best.keras", save_best_only=True,
    ),
    keras.callbacks.ReduceLROnPlateau(
        factor=0.5, patience=3,
    ),
]

# Train
history = model.fit(
    x_train, y_train,
    epochs=50,
    batch_size=32,
    validation_split=0.2,
    callbacks=callbacks,
)

External links

Exercise

CIFAR-10 의 위 파이프라인 전체 구현. 20 epoch 안에 test accuracy ≥70%. 스크립트를 train_cifar10.py 로 저장 — 향후 image classification 의 프로젝트 템플릿으로.

Progress

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

댓글 0

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

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