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

실전 — 이미지 + metadata 모델

~8 min · functional

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

track 전체를 실전에 투입

이 capstone 은 같은 feature space 에 안 사는 두 modality 를 융합해 — pixel 이랑 structured field. 상품 listing 을 떠올려: 사진 + 가격·카테고리·판매자 평점, 정확한 예측에 *둘 다* 필요한 경우. 이걸 한 tensor 로 그냥 쌓을 순 없어 — image 는 convolutional stack 을 원하고, 10 차원 metadata 벡터는 Dense layer 를 원해. Functional API 가 각 modality 에 제 처리 경로를 주면서도 하나의 학습 가능한 model 로 묶어주는 거야.

갈래 → 융합 → 예측

코드 블록이 표준 레시피고, 이 track 의 모든 패턴이 합쳐진 거야: 이름 붙은 입력 둘 (lesson 03), Conv → pool → GlobalAveragePooling2D 로 평평한 64 차원 feature 벡터까지 내리는 image branch, Dense layer 의 metadata branch, 그다음 layers.concatenate융합 하고 공유 head 가 예측. 숨은 주역은 GlobalAveragePooling2D — 공간 차원을 고정 길이 벡터로 접어서 입력 이미지 크기와 무관하게 두 branch 가 concat 호환이 되게 만들어.

multi-modal 설계를 지배하는 결정 하나: *어디서* 융합하나. 이 model 은 *late fusion* — 각 modality 를 독립 처리하다 head 근처에서야 만나. 이게 옳은 default: 단순하고, branch 마다 따로 튜닝 가능하고, metadata 경로 안 건드리고 pretrained image backbone 으로 갈아끼울 수 있어. *early fusion* (deep layer 전에 modality 섞기) 은 표현력이 더 클 수 있지만 학습·디버깅이 더 어려워. late 로 시작하고, modality 가 더 깊이 상호작용해야 한다는 증거 있을 때만 early 로 옮겨.

Code

multi-modal model — CNN image branch + Dense metadata branch, late fusion·python
# Image branch
image_input = keras.Input(shape=(64, 64, 3), name="image")
x = layers.Conv2D(32, 3, activation="relu")(image_input)
x = layers.MaxPooling2D(2)(x)
x = layers.Conv2D(64, 3, activation="relu")(x)
x = layers.GlobalAveragePooling2D()(x)
image_features = layers.Dense(64, activation="relu")(x)

# Metadata branch
meta_input = keras.Input(shape=(10,), name="metadata")
meta_features = layers.Dense(32, activation="relu")(meta_input)

# Merge and predict
combined = layers.concatenate([image_features, meta_features])
x = layers.Dense(64, activation="relu")(combined)
x = layers.Dropout(0.3)(x)
output = layers.Dense(5, activation="softmax")(x)

model = keras.Model(
    inputs=[image_input, meta_input],
    outputs=output,
)

External links

Exercise

코드 블록의 image+metadata model 을 짠 다음 regressor 로 바꿔: 마지막 head 를 layers.Dense(1) (activation 없음) 로 교체하고 loss='mse' 로 compile. image branch 는 작은 CNN (Conv 3 + Dense 1). synthetic data 로 학습하고 end-to-end 학습 확인 (5 epoch 동안 loss 감소).

Progress

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

댓글 0

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

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