즐거운프로그래밍

[딥러닝] 딥러닝 활용하기(패션 MNIST 데이터 셋 학습하기)

수수께끼 고양이 2023. 10. 30. 17:05
728x90
반응형

 

패션 MNIST 데이터 셋은 10개의 범주 (category)와 70,000개의 흑백 이미지로 구성되어 있습니다.

 

import tensorflow as tf

mnist = tf.keras.datasets.fashion_mnist

(X, YT), (x, yt) = mnist.load_data() #60000개의 학습데이터, 10000개의 검증데이터

X, x = X/255, x/255 # 60000x28x28, 10000x28x28
X, x = X.reshape((60000,784)), x.reshape((10000,784))

model = tf.keras.Sequential([
    tf.keras.Input(shape=(784,)),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dense(10, activation='softmax')
]) # 신경망 모양 결정(W, B 내부적 준비)

model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

model.fit(X,YT,epochs=5)
model.evaluate(x,yt)

 

 

 

728x90
반응형