Python Forum

Full Version: Increasing validation accuracy on a CNN
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I followed this tutorial: https://keras.io/examples/vision/image_c...m_scratch/
and I have built a CNN. After many tires I managed to make validation accuracy: 0.6907. But it does not increase and it does change:
Epoch 1/10
37/37 [==============================] - 511s 14s/step - loss: 0.7337 - accuracy: 0.4516 - val_loss: 0.6922 - val_accuracy: 0.6907
Epoch 2/10
37/37 [==============================] - 532s 14s/step - loss: 0.6004 - accuracy: 0.7044 - val_loss: 0.6877 - val_accuracy: 0.6907
Epoch 3/10
37/37 [==============================] - 541s 15s/step - loss: 0.4859 - accuracy: 0.8132 - val_loss: 0.6810 - val_accuracy: 0.6907
Epoch 4/10
37/37 [==============================] - 552s 15s/step - loss: 0.4076 - accuracy: 0.8483 - val_loss: 0.6729 - val_accuracy: 0.6907
Epoch 5/10
37/37 [==============================] - 513s 14s/step - loss: 0.3684 - accuracy: 0.8518 - val_loss: 0.6650 - val_accuracy: 0.6907
Epoch 6/10
37/37 [==============================] - 504s 14s/step - loss: 0.3375 - accuracy: 0.8638 - val_loss: 0.6574 - val_accuracy: 0.6907
Epoch 7/10
37/37 [==============================] - 463s 13s/step - loss: 0.3176 - accuracy: 0.8783 - val_loss: 0.6525 - val_accuracy: 0.6907
Epoch 8/10
37/37 [==============================] - 524s 14s/step - loss: 0.2883 - accuracy: 0.8937 - val_loss: 0.6490 - val_accuracy: 0.6907
Epoch 9/10
37/37 [==============================] - 524s 14s/step - loss: 0.2658 - accuracy: 0.9015 - val_loss: 0.6461 - val_accuracy: 0.6907
Epoch 10/10
37/37 [==============================] - 524s 14s/step - loss: 0.2576 - accuracy: 0.9049 - val_loss: 0.6429 - val_accuracy: 0.6907
How can I fix that? I have read tutorials and implemented changes but without any improvement...
I ran the same code and am not able to increase the val accuracy too. I recently did a similar kind of project. Try this out,I was able to gain 80% accuracy (validation)when trained from scratch. After that, I used a pre-trained model Xception to get better results. Here is a link to the article. I have classified 10 animals using a dataset from Kaggle.Recognizing HD images of animals with CNN from scratch
@hussainmujtaba: I am trying the code from the tutorial you have posted, but I got this error:

2020-06-20 12:17:24.726191: W tensorflow/core/kernels/data/generator_dataset_op.cc:103] Error occurred when finalizing GeneratorDataset iterator: Failed precondition: Python interpreter state is not initialized. The process may be terminated.
	 [[{{node PyFunc}}]]
Did you face something similar? If yes, how did you handle it?
Someone who can help, how to solve this error? Thanx...
Try running on Colab. I was usin tf 2.0 , can you make sure that you are also using same