모델을 컴파일하고 훈련시키는 코드로, 앞서 진행했던 코드와 동일합니다.
코드 8-11 모델 훈련
model2.compile(
optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy']
)
history2 = model2.fit(
X_train,
y_train,
epochs=1000,
validation_split=0.25,
batch_size=40,
verbose=2
)
다음은 모델 훈련 결과입니다.
Epoch 1/1000
3/3 - 0s - loss: 0.7546 - accuracy: 0.6889 - val_loss: 1.0772 - val_accuracy: 0.3333
Epoch 2/1000
3/3 - 0s - loss: 0.2344 - accuracy: 0.9667 - val_loss: 1.0729 - val_accuracy: 0.3333
Epoch 3/1000
3/3 - 0s - loss: 0.1445 - accuracy: 0.9889 - val_loss: 1.0825 - val_accuracy: 0.3333
...(중간 생략)...
Epoch 998/1000
3/3 - 0s - loss: 0.0162 - accuracy: 1.0000 - val_loss: 0.4138 - val_accuracy: 0.9000
Epoch 999/1000
3/3 - 0s - loss: 0.0262 - accuracy: 0.9778 - val_loss: 0.3249 - val_accuracy: 0.9000
Epoch 1000/1000
3/3 - 0s - loss: 0.0049 - accuracy: 1.0000 - val_loss: 0.2700 - val_accuracy: 0.9333