신경망과의 첫 만남

https://drive.google.com/uc?id=1UyDgI4HfpwCOeGOM9t_W5pWFgEjpicsF

from keras.datasets import mnist

(train_images, train_labels), (test_images, test_labels) = mnist.load_data()
train_images.shape
# (60000, 28, 28)

len(train_labels)
# 60000

train_labels
# array([5, 0, 4, ... , 5, 6, 8], dtype=unit8)

test_images.shape
# (10000, 28, 28)

len(test_labels)
# 10000

test_labels
# array([7, 2, 1, ... , 4, 5, 6], dtype=unit8)
from keras import models
from keras import layers

network = models.Sequential()
network.add(layers.Dense(512, activation='relu', input_shape=(28 * 28,)))
network.add(layers.Dense(10, activation='softmax'))
network.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])
train_images = train_images.reshape((60000, 28 * 28))
train_images = train_images.astype('float32') / 255

test_images = test_images.reshape((10000, 28 * 28))
test_images = test_images.astype('float32') / 255