facebookresearch / fairseq

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
MIT License
30.54k stars 6.41k forks source link

Zerodivisionerror problem caused by Hubert training #4628

Open 646312715 opened 2 years ago

646312715 commented 2 years ago

❓ Questions and Help

Before asking:

  1. search the issues.
  2. search the docs.

What is your question?

When I extracted the sixth layer feature of hubert_checkpoint.pt as km, and then did the pre-training of Hubert, I found that features.size(1)=0.On line 420 of hubert.py, it reported an error: zerodivisionerror.I hope every boss can see why they report mistakes,thanks.

Code

Traceback (most recent call last): File "fairseq_cli/hydra_train.py", line 27, in hydra_main _hydra_main(cfg) File "fairseq_cli/hydra_train.py", line 56, in _hydra_main distributed_utils.call_main(cfg, pre_main, kwargs) File "/home/gzf/fairseq/fairseq/distributed/utils.py", line 369, in call_main main(cfg, kwargs) File "/home/gzf/fairseq/fairseq_cli/train.py", line 190, in main valid_losses, should_stop = train(cfg, trainer, task, epoch_itr) File "/home/gzf/anaconda3/envs/hubertT/lib/python3.8/contextlib.py", line 75, in inner return func(*args, kwds) File "/home/gzf/fairseq/fairseq_cli/train.py", line 316, in train log_output = trainer.train_step(samples) File "/home/gzf/anaconda3/envs/hubertT/lib/python3.8/contextlib.py", line 75, in inner return func(*args, *kwds) File "/home/gzf/fairseq/fairseq/trainer.py", line 824, in train_step loss, sample_size_i, logging_output = self.task.train_step( File "/home/gzf/fairseq/fairseq/tasks/fairseq_task.py", line 517, in train_step loss, sample_size, logging_output = criterion(model, sample) File "/home/gzf/anaconda3/envs/hubertT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(input, kwargs) File "/home/gzf/fairseq/fairseq/criterions/hubert_criterion.py", line 61, in forward net_output = model(target_list=sample["target_list"], *sample["net_input"]) File "/home/gzf/anaconda3/envs/hubertT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(input, **kwargs) File "/home/gzf/fairseq/fairseq/models/hubert/hubert.py", line 448, in forward padding_mask = self.forward_padding_mask(features, padding_mask) File "/home/gzf/fairseq/fairseq/models/hubert/hubert.py", line 420, in forward_padding_mask extra = padding_mask.size(1) % features.size(1) ZeroDivisionError: integer division or modulo by zero

What have you tried?

What's your environment?

bnestor commented 2 years ago

I had the same issue. It went away by setting padding=True in the config file. Not sure if that was the parameter used in the original paper, but it sure isn't the default in hubert_base_librispeech.yaml.