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

How to avoid nan exception? #3

Open
auroua opened this issue Jul 30, 2019 · 3 comments
Open

How to avoid nan exception? #3

auroua opened this issue Jul 30, 2019 · 3 comments

Comments

@auroua
Copy link

auroua commented Jul 30, 2019

I am using ShangHaiTech Part A to train model, but only a few iteration it get the nan excpetion.

Traceback (most recent call last):
  File "Counting-with-Focus-for-Free/code/main.py", line 50, in <module>
    tf.app.run()
  File "Softwares/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "Counting-with-Focus-for-Free/code/main.py", line 44, in main
    model.train()
  File "Counting-with-Focus-for-Free/code/model.py", line 310, in train
    self.inputI_size, self.batch_size)
  File "Counting-with-Focus-for-Free/code/utils.py", line 120, in get_batch_patches
    batch_num[k] = dmap_temp.sum()/L
ValueError: cannot convert float NaN to integer

In this code

    dmap_temp = copy.deepcopy(rand_dmap[pos[0]:pos[0]+patch_width, pos[1]:pos[1]+patch_heigh])

the rand_dmap contains Nan. I have tried to modify the learning rate, but it have no effect.

@shizenglin
Copy link
Owner

Hi, for my experience, some of your density map ground truth are generated incorrectly, their values are Nan, please note some annotations of shanghai partA are not correct, such as the coordinates of some annotated points are labeled with a negative value or bigger than the size of image. So you need make sure your data is good before you use this code.

@auroua
Copy link
Author

auroua commented Jul 31, 2019

Could you share the code used to correct the shanghai partA training data?

@shizenglin
Copy link
Owner

Sorry, no code, you can do that.

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