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.

Error when setting num_candidates=1 and in dataset there's only one candidate during validation

See original GitHub issue

When setting args.num_candidates to 1, and the actual length of the candidates list of each entry is 1, I get this error during validation:

ERROR:ignite.engine.engine.Engine:Current run is terminating due to exception: For binary cases, y_pred must be comprised of 0's and 1's..
ERROR:ignite.engine.engine.Engine:Engine run is terminating due to exception: For binary cases, y_pred must be comprised of 0's and 1's..
ERROR:ignite.engine.engine.Engine:Engine run is terminating due to exception: For binary cases, y_pred must be comprised of 0's and 1's..
Traceback (most recent call last):
  File "./train-regular.py", line 277, in <module>
    train()
  File "./train-regular.py", line 269, in train
    trainer.run(train_loader, max_epochs=args.n_epochs)
  File "/usr/local/lib/python3.5/dist-packages/ignite/engine/engine.py", line 446, in run
    self._handle_exception(e)
  File "/usr/local/lib/python3.5/dist-packages/ignite/engine/engine.py", line 410, in _handle_exception
    raise e
  File "/usr/local/lib/python3.5/dist-packages/ignite/engine/engine.py", line 437, in run
    self._fire_event(Events.EPOCH_COMPLETED)
  File "/usr/local/lib/python3.5/dist-packages/ignite/engine/engine.py", line 345, in _fire_event
    func(self, *(event_args + args), **kwargs)
  File "./train-regular.py", line 223, in <lambda>
    trainer.add_event_handler(Events.EPOCH_COMPLETED, lambda _: evaluator.run(val_loader))
  File "/usr/local/lib/python3.5/dist-packages/ignite/engine/engine.py", line 446, in run
    self._handle_exception(e)
  File "/usr/local/lib/python3.5/dist-packages/ignite/engine/engine.py", line 410, in _handle_exception
    raise e
  File "/usr/local/lib/python3.5/dist-packages/ignite/engine/engine.py", line 433, in run
    hours, mins, secs = self._run_once_on_dataset()
  File "/usr/local/lib/python3.5/dist-packages/ignite/engine/engine.py", line 399, in _run_once_on_dataset
    self._handle_exception(e)
  File "/usr/local/lib/python3.5/dist-packages/ignite/engine/engine.py", line 410, in _handle_exception
    raise e
  File "/usr/local/lib/python3.5/dist-packages/ignite/engine/engine.py", line 392, in _run_once_on_dataset
    self._fire_event(Events.ITERATION_COMPLETED)
  File "/usr/local/lib/python3.5/dist-packages/ignite/engine/engine.py", line 345, in _fire_event
    func(self, *(event_args + args), **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/torch/autograd/grad_mode.py", line 49, in decorate_no_grad
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/ignite/metrics/metric.py", line 65, in iteration_completed
    self.update(output)
  File "/usr/local/lib/python3.5/dist-packages/ignite/metrics/accuracy.py", line 126, in update
    self._check_type((y_pred, y))
  File "/usr/local/lib/python3.5/dist-packages/ignite/metrics/accuracy.py", line 57, in _check_type
    self._check_binary_multilabel_cases((y_pred, y))
  File "/usr/local/lib/python3.5/dist-packages/ignite/metrics/accuracy.py", line 48, in _check_binary_multilabel_cases
    raise ValueError("For binary cases, y_pred must be comprised of 0's and 1's.")
ValueError: For binary cases, y_pred must be comprised of 0's and 1's.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dimeldocommented, Jan 15, 2020

@sshleifer Yeah, probably not worth changing the code that much. I was talking about a hack, like having the multiple-choice candidates be some random string, say “Something.”. Would that work?

0reactions
sshleifercommented, Jan 15, 2020

Sounds like it might to me. Try it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ELECTION CODE CHAPTER 145. WITHDRAWAL, DEATH ...
METHOD FOR WITHDRAWAL AS CANDIDATE. (a) To withdraw from an election, a candidate whose name is to appear on the ballot must request...
Read more >
Voter Registration Requirements for Candidates
House Bill 484 amends Election Code Section 141.001 to provide a new general rule (for most offices) that a candidate must be a...
Read more >
Title 52- Voting and Elections- Subtitle I and II
(1) All citizens of the United States who are otherwise qualified by law to vote at any election by the people in any...
Read more >
Elections: Running for Office as a Sticker or Write-in Candidate
How to Run as a Write-in Candidate. Write-in candidates run for offce without filing nomination papers. Your name won't appear on the ballot....
Read more >
Campaign Guide for Congressional Candidates
It summarizes the federal campaign finance laws applicable to candidate committees as of September 2021. Federal Election Commission. Washington, DC 20463.
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