이미지 분류를 위한 합성곱 신경망
분류용 합성곱 신경망은 합성곱 층(이미지 처리)과 완전 연결(Dense) 층(출력부)을 순차적으로 쌓아서 만듭니다. 이 연습 문제에서는 패션 데이터셋의 데이터를 분류하기 위한 작은 합성곱 신경망을 만들어 볼 거예요.
이 연습은 강의의 일부입니다
Keras로 배우는 이미지 모델링
연습 안내
- 네트워크의 입력 층을 만들기 위해
Conv2D층을 추가하세요. 커널 크기는 3×3을 사용하세요. 작업 공간에 있는img_rows와img_cols객체를 사용해 이 층의input_shape를 지정할 수 있어요. - 네트워크의 이미지 처리 부분과 분류 부분을 연결하기 위해
Flatten층을 추가하세요. - 데이터셋의 3가지 의류 카테고리를 분류할 수 있도록
Dense층을 추가하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Import the necessary components from Keras
from keras.models import Sequential
from keras.layers import Dense, Conv2D, Flatten
# Initialize the model object
model = Sequential()
# Add a convolutional layer
model.add(____(10, kernel_size=____, activation='relu',
input_shape=____))
# Flatten the output of the convolutional layer
model.add(____())
# Add an output layer for the 3 categories
model.add(____(____, activation='softmax'))