question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: probabilities contain NaN

See original GitHub issue

Trying run node2vec on my dataset using the example code from the ReadMe. During the walk generation, I am receiving the following error:

File "mtrand.pyx", line 920, in numpy.random.mtrand.RandomState.choice
ValueError: probabilities contain NaN

Any idea where this is coming from? My dataset is ~ 120 MB, but I can provide it if helpful

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
eliorccommented, Nov 30, 2020

@davidfstein I figured out the problem - the problem is that most of your weights are zero. In the algorithm node2vec, weights cannot be zero - because weights (after normalization) are treated as walk probabilities, so essentially using the weights you can control how strongly two nodes are connected.

Zero edge weight is essentially no edge, so you cannot use zero weights. So before applying node2vec, depending on your use case decide what to do with the zero weights, you can either train without weights, or decide anything else that serves your problem - as long as you avoid assigning zero weights.

Thanks for this issue, I will make sure in the next version to give a better error message for zero weights

0reactions
davidfsteincommented, Nov 30, 2020

That makes sense. Thanks @eliorc!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValueError: probabilities contain NaN in policy.py #376 - GitHub
Hey community, I made an environment with openai gym and now I am trying different settings and agents. I started with the agent...
Read more >
ValueError: probabilities contain NaN - python - Stack Overflow
I'm trying to write functions for LSTM Neural network using no library except numpy and getting error will exporting the txt file. def ......
Read more >
ValueError: probabilities contain NaNLoss : r/tensorflow - Reddit
I left my model train for overnight, I set max steps to 500k. At first it was doing great progress then after 6...
Read more >
ValueError: Input contains NaN, infinity or a value too large for ...
I got ValueError when predicting test data using a RandomForest model. My code: clf = RandomForestClassifier(n_estimators=10, max_depth=6, n_jobs=1, verbose= ...
Read more >
How to track a 'nan energy'? - Questions - PyMC Discourse
ValueError : Bad initial energy: nan. The model might be misspecified. How can I have clues about the random variable that produce such...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found