Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eval_transducer.sh decoder error #3

Closed
bliunlpr2020 opened this issue Jan 5, 2021 · 4 comments
Closed

eval_transducer.sh decoder error #3

bliunlpr2020 opened this issue Jan 5, 2021 · 4 comments

Comments

@bliunlpr2020
Copy link

When I run eval_transducer.sh, got the error:

Traceback (most recent call last):
File "/work0/pika//decoder/decode_transducer.py", line 264, in
main()
File "/work0/pika//decoder/decode_transducer.py", line 133, in main
len_batch + 100)
File "/work0/pika/decoder/transducer_decoder.py", line 182, in decode_batch
b.advance(out[:, j], self.t_idx[:, j], x_len[j])
File "/work0/pika/decoder/beam_transducer.py", line 140, in advance
self.scores -= self.lm_scorer_scale * self.lm_scores[prev_k]
IndexError: tensors used as indices must be long, byte or bool tensors

And I print some outputs:
beam_scores tensor([ -0.6430, -12.0813, -6.1094, ..., -8.2931, -11.2605, -11.8402],
device='cuda:0', grad_fn=) torch.Size([4232])
flat_beam_scores tensor([ -0.6430, -12.0813, -6.1094, ..., -8.2931, -11.2605, -11.8402],
device='cuda:0', grad_fn=) torch.Size([4232])
best_scores_id tensor([ 0, 156, 2995, 3703, 30, 718, 850, 1150], device='cuda:0') torch.Size([8]) <class 'torch.Tensor'>
num_words 4232 <class 'int'>
prev_k tensor([0.0000, 0.0369, 0.7077, 0.8750, 0.0071, 0.1697, 0.2009, 0.2717],
device='cuda:0') <class 'torch.Tensor'>

I use the pytorch 1.7.1.

Any suggestions? Thanks!

@cweng6
Copy link

cweng6 commented Jan 6, 2021

It seems / or // is deprecated for integer division in pytorch 1.7.0, could you try replacing this line (

prev_k = best_scores_id / num_words
)

prev_k = best_scores_id / num_words

to,

prev_k = torch.floor_divide(best_scores_id, num_words)

should solve your problem. I am not sure if this change will affect back compatibility with the older PyTorch version. Will submit a PR once confirmed.

@cweng6
Copy link

cweng6 commented Jan 14, 2021

@bliunlpr2020 please let us know if your issue has been fixed or not.

@bliunlpr2020
Copy link
Author

My issue has been fixed. Thank you very much! Maybe eval_transducer.sh miss "--cmn" .

@cweng6
Copy link

cweng6 commented Jan 15, 2021

It seems so. As long as '--cmn' option complies with the one used in the compute_cmvn_stat.py script, you should be good. If the issue has been fixed, could you please close it. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants