Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Generate features(features.npy) Problem-Flickr30K #24

Closed
jishan900 opened this issue Apr 13, 2018 · 2 comments
Closed

Generate features(features.npy) Problem-Flickr30K #24

jishan900 opened this issue Apr 13, 2018 · 2 comments
Labels

Comments

@jishan900
Copy link

jishan900 commented Apr 13, 2018

jishan@jishan-HP-ProBook-450-G3:~/Downloads/fy$ python convfeatures.py --data_path Dataset/flickr30k-images --inception_path ConvNets/inception_v4.pb
Extracting Features
#Images: 3
2018-04-14 01:05:43.501841: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
Traceback (most recent call last):
  File "convfeatures.py", line 122, in <module>
    forward_pass(io, args.data_path)
  File "convfeatures.py", line 80, in forward_pass
    print "Progress:" + str(((n_batch) / float(n_batch) * 100)) + "%\n"
ZeroDivisionError: float division by zero

How can solve that problem. I faced this problem when i want to generate features.npy file. Please help me. Thanks in advance.

@aayux
Copy link
Member

aayux commented Jun 18, 2018

Thanks for pointing this out, this is a bug and one of the many inherent flaws of Python 2.

You're using 3 images in this example, and the batch size is 10. Further because <int> / <int> is pure integer division in Python 2, when we calculate n_batch = len(files) / batch_size here the result is that n_batch = 0 and so (n_batch) / float(n_batch) will quite naturally throw a ZeroDivisionError.

This never came to notice because we never used less than batch_size number of images. Some ways to fix it are:

  1. Reduce the batch_size to 1 (or 2) -- especially if you only have 3 images in a sample.
  2. Supply more images.
  3. Import from __future__ import division at the very beginning of convfeatures.py.

@aayux
Copy link
Member

aayux commented Jun 18, 2018

Closing as resolved from my end. The identified bug will from now on be referred to in #27.

@aayux aayux closed this as completed Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants