Closed orangelulu closed 3 years ago
Hello, can anybody help me with this issue, since it looks like the forward function of decoder in wav2vec_asr.py is not right, the 'prev_output_tokens' need to be given in forward process while it does't exist. Moreover in the source code I don't find the shift right operation in the s2s decoder.
def forward(self, **kwargs):
encoder_out = self.encoder(tbc=False, **kwargs)
decoder_out = self.decoder(encoder_out=encoder_out, **kwargs)
return decoder_out ```
i'm facing the same problem , can anyone help with that ?
you need to set task.autoregressive=true for seq2seq models. i'll add a check for this
how to set task.autoregressive = true?
@zxk19981227 fairseq-hydra-train model.w2v_path=/path/to/pretrained_model/ task.data=/path/to/data +task.autoregressive=true --config-dir /path/to/config/dir/ --config-name something.yaml
Hello, can anybody help me with this issue, since it looks like the forward function of decoder in wav2vec_asr.py is not right, the 'prev_output_tokens' need to be given in forward process while it does't exist. Moreover in the source code I don't find the shift right operation in the s2s decoder.
def forward(self, **kwargs): encoder_out = self.encoder(tbc=False, **kwargs) decoder_out = self.decoder(encoder_out=encoder_out, **kwargs) return decoder_out ```
same prolem when run inference model wav2vec_seq2seq
I am a beginner and facing this issue, can anyone guide me to resolve it?
hi guys, got the same problem today, has anyone found the solution for this?
Did anyone figure out how to fix this? Facing this issue now and I'm completely stuck..
Hello, can anybody help me with this issue, since it looks like the forward function of decoder in wav2vec_asr.py is not right, the 'prev_output_tokens' need to be given in forward process while it does't exist. Moreover in the source code I don't find the shift right operation in the s2s decoder.
def forward(self, **kwargs): encoder_out = self.encoder(tbc=False, **kwargs) decoder_out = self.decoder(encoder_out=encoder_out, **kwargs) return decoder_out ```
same prolem when run inference model wav2vec_seq2seq
use the previous token from the encoder in timestep t-1 as input for the decoder in timestep t:
def get_emissions_transformer_decoder(self, models, encoder_input):
"""Run encoder and normalize emissions"""
model = models[0]
encoder_out = model.encoder(**encoder_input)
batch_size = encoder_out["encoder_out"].size(1)
assert batch_size == 1
hyps = torch.ones([1, 1], dtype=torch.long, device=encoder_out["encoder_out"].device).fill_(self.tgt_dict.eos())
final_logprobs_output = torch.empty([1, 1, len(self.tgt_dict)], device=encoder_out["encoder_out"].device)
for i in range(1, encoder_out["encoder_out"].size(0)):
decoder_out, _ = model.decoder(hyps, encoder_out)
if hasattr(model, "get_logits"):
emissions = model.get_logits(decoder_out) # no need to normalize emissions
else:
emissions = model.get_normalized_probs(decoder_out, log_probs=True)
emissions = emissions.float().contiguous()
last_prob = emissions[-1,:].unsqueeze(0).unsqueeze(0)
final_logprobs_output = torch.cat([final_logprobs_output, last_prob], 1)
tokens = last_prob.argmax(dim=-1)
hyps = torch.cat([hyps, tokens], 1)
if torch.eq(hyps[:, -1], self.tgt_dict.eos()).view(-1, 1):
break
return final_logprobs_output.float().cpu().contiguous()
🐛 Bug
To Reproduce
Steps to reproduce the behavior (always include the command you ran):
2021-01-27 00:45:39 | INFO | fairseq.utils | rank 1: capabilities = 7.0 ; total memory = 31.719 GB ; name = Tesla V100-SXM2-32GB
2021-01-27 00:45:39 | INFO | fairseq.utils | rank 2: capabilities = 7.0 ; total memory = 31.719 GB ; name = Tesla V100-SXM2-32GB
2021-01-27 00:45:39 | INFO | fairseq.utils | rank 3: capabilities = 7.0 ; total memory = 31.719 GB ; name = Tesla V100-SXM2-32GB
2021-01-27 00:45:39 | INFO | fairseq.utils | CUDA enviroments for all 4 workers 2021-01-27 00:45:39 | INFO | fairseq_cli.train | training on 4 devices (GPUs/TPUs) 2021-01-27 00:45:39 | INFO | fairseq_cli.train | max tokens per GPU = None and batch size per GPU = 32 2021-01-27 00:45:39 | INFO | fairseq.trainer | no existing checkpoint found spanish_100h_s2s/checkpoint_last.pt 2021-01-27 00:45:39 | INFO | fairseq.trainer | loading train data for epoch 1 2021-01-27 00:45:39 | INFO | fairseq.data.audio.raw_audio_dataset | loaded 24103, skipped 0 samples 2021-01-27 00:45:40 | INFO | fairseq.trainer | begin training epoch 1 Traceback (most recent call last): File "/opt/tiger/fairseq/fairseq_cli/hydra_train.py", line 70, in
-- Process 0 terminated with the following error: Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/torch/multiprocessing/spawn.py", line 19, in _wrap fn(i, *args) File "/opt/tiger/fairseq/fairseq/distributed_utils.py", line 302, in distributed_main main(cfg, kwargs) File "/opt/tiger/fairseq/fairseq_cli/train.py", line 138, in main valid_losses, should_stop = train(cfg, trainer, task, epoch_itr) File "/usr/lib/python3.7/contextlib.py", line 74, in inner return func(*args, *kwds) File "/opt/tiger/fairseq/fairseq_cli/train.py", line 235, in train log_output = trainer.train_step(samples) File "/usr/lib/python3.7/contextlib.py", line 74, in inner return func(args, kwds) File "/opt/tiger/fairseq/fairseq/trainer.py", line 536, in train_step ignore_grad=is_dummy_batch, File "/opt/tiger/fairseq/fairseq/tasks/fairseq_task.py", line 428, in train_step loss, sample_size, logging_output = criterion(model, sample) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, kwargs) File "/opt/tiger/fairseq/fairseq/criterions/cross_entropy.py", line 35, in forward net_output = model(sample["net_input"]) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, kwargs) File "/opt/tiger/fairseq/fairseq/legacy_distributed_data_parallel.py", line 83, in forward return self.module(*inputs, *kwargs) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, kwargs) File "/opt/tiger/fairseq/fairseq/models/wav2vec/wav2vec2_asr.py", line 249, in forward decoder_out = self.decoder(encoder_out=encoder_out, *kwargs) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, **kwargs) TypeError: forward() missing 1 required positional argument: 'prev_output_tokens'
Code sample
Expected behavior
Environment
pip
, source):pipAdditional context
no