https://opentutorials.org/module/5268/29792
다섯번째 딥러닝 완성 - LeNet - Tensorflow 102 - 이미지 분류(CNN)
수업소개 LeNet-5 모델을 완성하고, CIFAR10 이미지 학습을 진행합니다. 강의 실습 소스코드 colab | backend.ai ########################### # 라이브러리 사용 import tensorflow as tf import pandas as pd #################
opentutorials.org
11강 Lenet
12강 Lenet (실습)
실습 코드 및 설명 드라이브에 업로드
###########################
# 라이브러리 사용
import tensorflow as tf
import pandas as pd
###########################
# 데이터를 준비합니다.
(독립, 종속), _ = tf.keras.datasets.cifar10.load_data()
종속 = pd.get_dummies(종속.reshape(50000))
print(독립.shape, 종속.shape)
###########################
# 모델을 완성합니다.
X = tf.keras.layers.Input(shape=[32, 32, 3])
H = tf.keras.layers.Conv2D(6, kernel_size=5, activation='swish')(X)
H = tf.keras.layers.MaxPool2D()(H)
H = tf.keras.layers.Conv2D(16, kernel_size=5, activation='swish')(H)
H = tf.keras.layers.MaxPool2D()(H)
H = tf.keras.layers.Flatten()(H)
H = tf.keras.layers.Dense(120, activation='swish')(H)
H = tf.keras.layers.Dense(84, activation='swish')(H)
Y = tf.keras.layers.Dense(10, activation='softmax')(H)
model = tf.keras.models.Model(X, Y)
model.compile(loss='categorical_crossentropy', metrics='accuracy')
###########################
# 모델을 학습하고
model.fit(독립, 종속, epochs=10)
###########################
# 모델을 이용합니다.
pred = model.predict(독립[0:5])
pd.DataFrame(pred).round(2)
# 정답 확인
종속[0:5]
# 모델 확인
model.summary()