acc += history_fine.history['accuracy']
val_acc += history_fine.history['val_accuracy']
loss += history_fine.history['loss']
val_loss += history_fine.history['val_loss']
plt.figure(figsize=(8, 8))
plt.subplot(2, 1, 1)
plt.plot(acc, label='Training Accuracy')
plt.plot(val_acc, label='Validation Accuracy')
plt.ylim([0.8, 1])
plt.plot([initial_epochs-1,initial_epochs-1],
plt.ylim(), label='Start Fine Tuning')
plt.legend(loc='lower right')
plt.title('Training and Validation Accuracy')
plt.subplot(2, 1, 2)
plt.plot(loss, label='Training Loss')
plt.plot(val_loss, label='Validation Loss')
plt.ylim([0, 1.0])
plt.plot([initial_epochs-1,initial_epochs-1],
plt.ylim(), label='Start Fine Tuning')
plt.legend(loc='upper right')
plt.title('Training and Validation Loss')
plt.xlabel('epoch')
plt.show()
Based on this data, I extracted from a comment of yours:
initial_epochs = 2.0
val_acc = [0.6486, 0.6486, 0.6486]
acc = [0.7000, 0.7000, 0.7000]
loss = [0.6015, 0.5935, 0.4653]
val_loss = [0.6964, 0.5359, 0.6738]
I can plot with:
plt.figure(figsize=(8, 8))
plt.subplot(2, 1, 1)
plt.plot(acc, label='Training Accuracy')
plt.plot(val_acc, label='Validation Accuracy')
plt.ylim([0.4, 1]) # You had plt.ylim([0.8, 1])
plt.plot([initial_epochs-1, initial_epochs-1], plt.ylim(), label='Start Fine Tuning')
plt.legend(loc='lower right')
plt.grid() # I added a grid for both plots
plt.title('Training and Validation Accuracy')
plt.subplot(2, 1, 2)
plt.plot(loss, label='Training Loss')
plt.plot(val_loss, label='Validation Loss')
plt.ylim([0, 1.0])
plt.plot([initial_epochs-1, initial_epochs-1], plt.ylim(), label='Start Fine Tuning')
plt.legend(loc='upper right')
plt.title('Training and Validation Loss')
plt.xlabel('epoch')
plt.grid() # I added a grid for both plots
plt.show()
I assume (based on the data I have), that the problem was due to plt.ylim([0.8, 1])
, because val_acc
, as well as acc
both, were < 0.8
, meaning the axis limits were focusing on a part of the plot where no data is.
See the following plot with plt.ylim([0.4, 1])
:
-
$\begingroup$ Thanks sir my first graph works well but validation loss graph have still problem it is showing validation loss curve only $\endgroup$ – Sukhpal Kaur Apr 8 at 12:01
-
$\begingroup$ Have you checked the min and max values of the training loss? Might it be outside of the y-axis limits? $\endgroup$ – Albo Apr 8 at 12:17
-
-
$\begingroup$ Epoch 18/20 4/4 [==============================] - 59s 15s/step - loss: 0.5577 - accuracy: 0.8850 - val_loss: 0.7220 - val_accuracy: 0.5000 Epoch 19/20 4/4 [==============================] - 59s 15s/step - loss: 0.5488 - accuracy: 0.9100 - val_loss: 0.7214 - val_accuracy: 0.5000 Epoch 20/20 4/4 [==============================] - 65s 16s/step - loss: 0.5464 - accuracy: 0.9200 - val_loss: 0.7204 - val_accuracy: 0.5000 $\endgroup$ – Sukhpal Kaur Apr 8 at 12:20
-
$\begingroup$ If I use this data:
loss = [0.5577, 0.5488, 0.5464] acc = [0.8850, 0.9100, 0.9200] val_loss = [0.7220, 0.7214, 0.7204] val_acc = [0.5000, 0.5000, 0.5000]
I still get a nice graph, similar to the one above. $\endgroup$ – Albo Apr 8 at 12:30
acc
,val_acc
,loss
andval_loss
(like the first 10 values of each?). $\endgroup$ – Albo Apr 8 at 10:05