Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

ZeroDivisionError from f1 function #3

@willystumblr

Description

@willystumblr

Hi,

I'm continuously facing an issue during an epoch when running train_baselines.py with following arguments:

python train_baselines.py --config-name closed model=binary_dpr_nl seed=1 project=local-closed-1

It says that ZeroDivisionError occurred from model/seq2seq.py, especially when calling f1 function. Below is the error message:

  File "/home/minseo/.conda/envs/RoMQA-3.7/lib/python3.7/site-packages/pytorch_lightning/overrides/base.py", line 110, in forward
    return self._forward_module.validation_step(*inputs, **kwargs)
  File "/home/minseo/.conda/envs/RoMQA-3.7/lib/python3.7/site-packages/wrangl/learn/supervised.py", line 196, in validation_step
    metrics = self.compute_metrics(pred, gold)
  File "/home/minseo/SemanticFiltering/romqa/model/seq2seq.py", line 81, in compute_metrics
    m = {k: v for k, v in f1(pred, gold, ignore_empty=True).items()}
  File "/home/minseo/.conda/envs/RoMQA-3.7/lib/python3.7/site-packages/wrangl/learn/metrics.py", line 78, in __call__
    return {k: sum(v)/len(v) for k, v in metrics.items()}
  File "/home/minseo/.conda/envs/RoMQA-3.7/lib/python3.7/site-packages/wrangl/learn/metrics.py", line 78, in <dictcomp>
    return {k: sum(v)/len(v) for k, v in metrics.items()}
ZeroDivisionError: division by zero

I guess it occurs because the score evaluates to zero at some point in the train set, but I wonder why it happens. Would you check this issue? Thank you in advance.

PS: Just in case this might help explain the issue, I slightly increased the value of batch size, gpus from classify.yaml and added strategy='ddp' option to pl.Trainer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions