다음은 모델을 훈련시킨 결과입니다.
Epoch 1/4
195/195 [==============================] - 18s 91ms/step - loss: 0.4792 - accuracy: 0.7595
Epoch 2/4
195/195 [==============================] - 28s 145ms/step - loss: 0.3136 - accuracy: 0.8711 - val_loss: 0.3617 - val_accuracy: 0.8397
Epoch 3/4
195/195 [==============================] - 20s 103ms/step - loss: 0.2613 - accuracy: 0.8954
Epoch 4/4
195/195 [==============================] - 27s 137ms/step - loss: 0.2258 - accuracy: 0.9129 - val_loss: 0.4071 - val_accuracy: 0.8243
<tensorflow.python.keras.callbacks.History at 0x21fb632da90>
다음과 같이 모델에 대한 평가를 확인하는 코드를 추가합니다.
코드 7-14 모델 평가
print("훈련 데이터셋 평가...")
(loss, accuracy) = model.evaluate(train_data, verbose=0)
print("loss={:.4f}, accuracy: {:.4f}%".format(loss,accuracy * 100))
print("테스트 데이터셋 평가...")
(loss, accuracy) = model.evaluate(test_data, verbose=0)
print("loss={:.4f}, accuracy: {:.4f}%".format(loss,accuracy * 100))
t1 = time.time()
print('시간:', t1-t0)