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.

divide by zero error

See original GitHub issue

Hello, thank you for the work. I am facing the issue of dividing by zero error in the line below when calling the sample function to sample memory. Any idea why?

is_weight /= is_weight.max()

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

6reactions
Jspujolcommented, Nov 7, 2019

Hello, I also find that the uninitialized samples will be sampled and got the unwanted data “0”. I tried to find out the root caused but failed. Did you guys figure out the reason? @stormont @emunaran Many thanks!

Hi there! I faced the same issue and what I did is to sample another value of that same interval, until it is not an integer (given that the capacity is initialized to np.zeros ). In the prioritized memory I added the following:

for i in range(n):
            a = segment * i
            b = segment * (i + 1)
            while True:
                s = random.uniform(a, b)
                (idx, p, data) = self.tree.get(s)
                if not isinstance(data, int):
                    break
            priorities.append(p)
            batch.append(data)
            idxs.append(idx)

This did the trick for me. Hope it does the same to you.

0reactions
being-aeryscommented, Dec 1, 2020

If anyone is still wondering why it pulls 0 from the replay memory, it is because the location in the replay memory that was sampled was not filled out yet and thus contained the initial values with which we initialized the replay buffer. i.e., 0’s. If you set a condition that the training does not start until the buffer is completely filled, then you never encounter this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to correct a #DIV/0! error - Microsoft Support
Microsoft Excel shows the #DIV/0! error when a number is divided by zero (0). It happens when you enter a simple formula like...
Read more >
How to fix the #DIV/0! error - Excel formula - Exceljet
The #DIV/0! error appears when a formula attempts to divide by zero, or a value equivalent to zero. Although a #DIV/0! error is...
Read more >
How to Avoid #DIV/0 Errors in Excel
1. Create a column for your formula. (e.g. Column E Conv Cost) 2. Click the next cell down in that column. (e.g., E2)...
Read more >
How to Get Rid of #DIV/0! Error in Excel? Easy Formulas!
In Excel, you will get a DIV error when you have a formula where there is a division and the divisor is 0....
Read more >
Division by zero - Wikipedia
For other uses, see Division by zero (disambiguation). ... is contained in Anglo-Irish philosopher George Berkeley's criticism of infinitesimal calculus in 1734 ...
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