4. 에포크를 5로 지정하여 학습하기

    >>> model.compile(optimizer='adam',
    >>>     loss='sparse_categorical_crossentropy',
    >>>     metrics=['accuracy'])
    >>> model.fit(train_images, train_labels, epochs=5)
    Train on 60000 samples
    Epoch 1/5
    60000/60000 [==============================] - 49s 818us/sample - loss: 0.1377 - accuracy: 0.9566
    Epoch 2/5
    60000/60000 [==============================] - 47s 777us/sample - loss: 0.0449 - accuracy: 0.9858
    Epoch 3/5
    60000/60000 [==============================] - 40s 670us/sample - loss: 0.0320 - accuracy: 0.9902
    Epoch 4/5
    60000/60000 [==============================] - 39s 642us/sample - loss: 0.0247 - accuracy: 0.9919
    Epoch 5/5
    60000/60000 [==============================] - 50s 826us/sample - loss: 0.0186 - accuracy: 0.9938
    10000/1 - 3s - loss: 0.0266 - accuracy: 0.9845

    5. 평가하기

    >>> test_loss, test_acc = model.evaluate(test_images, test_labels, verbose=2)
    >>> print(test_acc)
    0.9845   # 정분류율이 98.45%로 개선
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.