Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial accuracy 0.000??? #8

Closed
sainisanjay opened this issue Jul 3, 2018 · 13 comments
Closed

Partial accuracy 0.000??? #8

sainisanjay opened this issue Jul 3, 2018 · 13 comments

Comments

@sainisanjay
Copy link

Hello @Horea94
I have used useCkpt = False during training and it gave me error during testing as per below.

File "network/fruit_test_net.py", line 82, in <module>
    saver.restore(sess, ckpt.model_checkpoint_path)
AttributeError: 'NoneType' object has no attribute 'model_checkpoint_path'

In order to resolve above issue i commented #saver.restore(sess, ckpt.model_checkpoint_path) in the fruit_test_net.py test script. After that it runs well but it gave me Partial accuracy 0.000.

Predicted 5 out of 100; partial accuracy 0.0000
Predicted 8 out of 200; partial accuracy 0.0000
Predicted 9 out of 300; partial accuracy 0.0000
Predicted 10 out of 400; partial accuracy 0.0000
Predicted 12 out of 500; partial accuracy 0.0000
Predicted 13 out of 600; partial accuracy 0.0000
Predicted 16 out of 700; partial accuracy 0.0000
Predicted 19 out of 800; partial accuracy 0.0000
Predicted 20 out of 900; partial accuracy 0.0000
Predicted 23 out of 1000; partial accuracy 0.0000
Predicted 27 out of 1100; partial accuracy 0.0000
Predicted 28 out of 1200; partial accuracy 0.0000
Predicted 32 out of 1300; partial accuracy 0.0000
Predicted 34 out of 1400; partial accuracy 0.0000
Predicted 38 out of 1500; partial accuracy 0.0000
```
any idea??
@Horea94
Copy link
Owner

Horea94 commented Jul 3, 2018

The commented line #saver.restore(sess, ckpt.model_checkpoint_path) is responsible for loading the saved model . Without it , the script does not load anything and tests a model that was not trained, so the result is 0% accuracy.

@sainisanjay
Copy link
Author

Okay, i have commented out saver.restore(sess, ckpt.model_checkpoint_path) from the fruit_test_net.py test script. I am getting following error, may i know how to resolve this.

File "network/fruit_test_net.py", line 82, in <module>
  saver.restore(sess, ckpt.model_checkpoint_path)
AttributeError: 'NoneType' object has no attribute 'model_checkpoint_path'

@Horea94
Copy link
Owner

Horea94 commented Jul 3, 2018

It seems that the ckpt object is not properly initialized by the
ckpt = tf.train.get_checkpoint_state(checkpoint_dir) line
Did you ensure that the files resulted from the fruit_train_net.py script are all in the folder pointed by the "checkpoint_dir" variable?

@sainisanjay
Copy link
Author

sainisanjay commented Jul 3, 2018

Yes i can see in the fruit_models folder which is created during training. The following 5 files available

/fruit_models/checkpoint   (381 bytes)
/fruit_models/graph.pbtxt  (284.3 kb)
/fruit_models/model.ckpt.data-00000-of-00001 (83.7 MB)
/fruit_models/model.ckpt.index  (1.5 kb)
/fruit_models/model.ckpt.meta  (145.2 kb)

Even i tried by doing fresh training:

time: 21.5204 step: 1 loss: 4.0560 accuracy: 0.0600
time: 117.3164 step: 500 loss: 0.1250 accuracy: 0.9700
time: 118.0530 step: 1000 loss: 0.0824 accuracy: 0.9700
time: 118.3158 step: 1500 loss: 0.0165 accuracy: 1.0000
time: 119.6045 step: 2000 loss: 0.0233 accuracy: 0.9900
time: 119.7569 step: 2500 loss: 0.0021 accuracy: 1.0000
time: 116.7455 step: 3000 loss: 0.0091 accuracy: 1.0000
time: 111.8938 step: 3500 loss: 0.0205 accuracy: 1.0000
time: 110.3421 step: 4000 loss: 0.0279 accuracy: 0.9800
time: 108.9707 step: 4500 loss: 0.0203 accuracy: 0.9900
time: 109.2560 step: 5000 loss: 0.0210 accuracy: 0.9800
time: 106.7813 step: 5500 loss: 0.0011 accuracy: 1.0000
time: 105.4543 step: 6000 loss: 0.0025 accuracy: 1.0000
time: 108.1577 step: 6500 loss: 0.0763 accuracy: 0.9600
time: 109.1269 step: 7000 loss: 0.0107 accuracy: 0.9900
time: 108.0914 step: 7500 loss: 0.0218 accuracy: 0.9800
time: 114.1078 step: 8000 loss: 0.0116 accuracy: 1.0000
time: 119.6590 step: 8500 loss: 0.0094 accuracy: 1.0000
time: 119.5516 step: 9000 loss: 0.0110 accuracy: 1.0000
time: 117.5011 step: 9500 loss: 0.0110 accuracy: 0.9900
time: 113.2210 step: 10000 loss: 0.0008 accuracy: 1.0000
time: 106.1483 step: 10500 loss: 0.0062 accuracy: 1.0000
time: 106.7721 step: 11000 loss: 0.0160 accuracy: 0.9800
time: 107.3277 step: 11500 loss: 0.0050 accuracy: 1.0000
time: 107.9952 step: 12000 loss: 0.0005 accuracy: 1.0000
time: 117.4758 step: 12500 loss: 0.0023 accuracy: 1.0000

But still same problem during testing

@Horea94
Copy link
Owner

Horea94 commented Jul 3, 2018

What is the value of the "checkpoint_dir" variable when it executes
ckpt = tf.train.get_checkpoint_state(checkpoint_dir) ?
Is it the same as the path to the folder with those 5 files?

@sainisanjay
Copy link
Author

Yes its has same.

@sainisanjay
Copy link
Author

sainisanjay commented Jul 3, 2018

I have resolved that issues but accuracy is coming always 0

Predicted 86 out of 100; partial accuracy 0.0000
Predicted 181 out of 200; partial accuracy 0.0000
Predicted 277 out of 300; partial accuracy 0.0000
Predicted 367 out of 400; partial accuracy 0.0000
Predicted 465 out of 500; partial accuracy 0.0000
Predicted 560 out of 600; partial accuracy 0.0000
Predicted 648 out of 700; partial accuracy 0.0000

@Horea94
Copy link
Owner

Horea94 commented Jul 3, 2018

From the prints it looks like it counts the number of correctly classified images as well as the total number of images.
I think the issue is caused by python rounding down the result. Please try changing in the print the "correct / (total_test_images - images_left_to_process)" into
"float(correct / (total_test_images - images_left_to_process))"

@sainisanjay
Copy link
Author

I guess you are right but still showing same accuracy 0.0000. No luck

Predicted 11437 out of 12300; partial accuracy 0.0000
Predicted 11531 out of 12400; partial accuracy 0.0000
Predicted 11618 out of 12500; partial accuracy 0.0000
0

@Horea94
Copy link
Owner

Horea94 commented Jul 3, 2018

I think I was mistaken. Please try
float(correct) / float(total_test_images - images_left_to_process)
to let python know that you want a division between 2 floats, and the result is expected to be a float.
What version of python are you using, because I cannot replicate this issue with my version?
I use Python 3.6.6.

@sainisanjay
Copy link
Author

Great now its working absolutely fine. just one more doubt while detecting fruits from detect_fruits.py i am getting error as per below:

FailedPreconditionError (see above for traceback): .../Fruit-Images-Dataset/test-multiple_fruits; Is a directory
	 [[Node: ReaderReadV2_1 = ReaderReadV2[_device="/job:localhost/replica:0/task:0/device:CPU:0"](WholeFileReaderV2, input_producer_1)]]
	 [[Node: DecodeJpeg_1/_93 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_5_DecodeJpeg_1", tensor_type=DT_UINT8, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

I am running as per:
.../Fruit-Images-Dataset/src/image_classification$python fruit_detection/detect_fruits.py --image_path=/home/sanjay.saini/Deeplearning/DeepTensorFlow/My_TensorFlow_tutorials/Fruits_Classification/Fruit-Images-Dataset/test-multiple_fruits

Any idea whats wrong?

@Horea94
Copy link
Owner

Horea94 commented Jul 3, 2018

For this script you need to provide the path to a jpg file, not the folder.
Something like
.../Fruit-Images-Dataset/src/image_classification$python fruit_detection/detect_fruits.py --image_path=/home/sanjay.saini/Deeplearning/DeepTensorFlow/My_TensorFlow_tutorials/Fruits_Classification/Fruit-Images-Dataset/test-multiple_fruits/apple.jpg

@sainisanjay
Copy link
Author

Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants