앞서 정의한 네트워크를 이용하여 모델을 훈련시켜 봅시다.
코드 5-29 모델 훈련
history = model.fit(train_generator,
epochs=10,
validation_data=valid_generator,
verbose=2)
코드를 실행하면 다음과 같이 모델이 훈련됩니다.
Epoch 1/10
13/13 - 22s - loss: 0.8898 - accuracy: 0.7403 - val_loss: 0.3419 - val_accuracy: 0.8673
Epoch 2/10
13/13 - 20s - loss: 0.3538 - accuracy: 0.8675 - val_loss: 0.2667 - val_accuracy: 0.9184
Epoch 3/10
13/13 - 21s - loss: 0.2982 - accuracy: 0.9065 - val_loss: 0.2420 - val_accuracy: 0.9082
...(중간 생략)...
Epoch 8/10
13/13 - 20s - loss: 0.1357 - accuracy: 0.9429 - val_loss: 0.2321 - val_accuracy: 0.8878
Epoch 9/10
13/13 - 20s - loss: 0.1299 - accuracy: 0.9455 - val_loss: 0.1902 - val_accuracy: 0.9184
Epoch 10/10
13/13 - 22s - loss: 0.1284 - accuracy: 0.9506 - val_loss: 0.2279 - val_accuracy: 0.8980