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.

Division by zero error in training related to number of samples

See original GitHub issue

Getting

Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/app/robosat/tools/__main__.py", line 60, in <module>
    args.func(args)
  File "/app/robosat/tools/train.py", line 147, in main
    val_hist = validate(val_loader, num_classes, device, net, criterion)
  File "/usr/lib/python3.5/contextlib.py", line 30, in inner
    return func(*args, **kwds)
  File "/app/robosat/tools/train.py", line 245, in validate
    "mcc": metrics.get_mcc(),
  File "/app/robosat/metrics.py", line 66, in get_mcc
    (self.tp + self.fp) * (self.tp + self.fn) * (self.tn + self.fp) * (self.tn + self.fn)
ZeroDivisionError: float division by zero

. . . following the completion of a single epoch (out of a total of 1) in this workflow. It’s unclear from the traceback where exactly the zero is being invoked, or how it could be fixed in either the config .tomls or the inputs. It seems related to this division, but it’s not clear how a situation where num_samples = 0 could get through the validity check just above it.

cc @jacquestardie

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ocourtincommented, Oct 8, 2018

@daniel-j-h New related PR: https://github.com/mapbox/robosat/pull/127

@wboykinm Thanks for the test and report, and replyied on the ‘newer and bigger’ one…

1reaction
wboykinmcommented, Oct 8, 2018

@ocourtin That seems to have done the trick on the division by zero error! Thanks for adding the handler!

(Of course I’m on to newer and bigger failures, but that doesn’t appear related and I’ll try some debugging before I whine about that one.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Divide by Zero error when training · Issue #558 · thtrieu/darkflow
To train my own dataset which are 20 images of car with license plate annotated. The labels.txt contains only one line license plate...
Read more >
DIVIDE_BY_ZERO error class - Azure Databricks
In this article. Parameters; Explanation; Mitigation; Examples; Related. Division by zero. To return NULL instead, use try_divide .
Read more >
Exception has occurred: ZeroDivisionError division by zero ...
It is giving you a division by zero error because len(test_lengths[i]) in count/len(test_lengths[i])*100 is 0, and you know that a number ...
Read more >
How is division by zero avoided when implementing back ...
I am building a neural network for which I am using the sigmoid function as the activation function for the single output neuron...
Read more >
How to fix the #DIV/0! error - Excel formula - Exceljet
Although a #DIV/0! error is caused by an attempt to divide by zero, ... For example, in the screen below, we are calculating...
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