xinjli / allosaurus

Allosaurus is a pretrained universal phone recognizer for more than 2000 languages
GNU General Public License v3.0
532 stars 85 forks source link

Runtime Error #17

Closed Jiawen-Yan closed 3 years ago

Jiawen-Yan commented 3 years ago

Thanks for the sharing the codes. During running, I encountered the following runtime error:

Traceback (most recent call last): File "/opt/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/opt/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Users/jiawen/Google Drive/WorkSpace/github/allosaurus/allosaurus/run.py", line 61, in <module> phones = recognizer.recognize(args.input, args.lang, args.topk) File "/Users/jiawen/Google Drive/WorkSpace/github/allosaurus/allosaurus/app.py", line 69, in recognize tensor_batch_lprobs = self.am(tensor_batch_feat, tensor_batch_feat_len) File "/opt/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in __call__ result = self.forward(*input, **kwargs) File "/Users/jiawen/Google Drive/WorkSpace/github/allosaurus/allosaurus/am/allosaurus_torch.py", line 88, in forward hidden_pack_sequence, _ = self.blstm_layer(pack_sequence) File "/opt/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in __call__ result = self.forward(*input, **kwargs) File "/opt/anaconda3/lib/python3.7/site-packages/torch/nn/modules/rnn.py", line 573, in forward self.num_layers, self.dropout, self.training, self.bidirectional) RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #2 'mat1' in call to _th_addmm

I used Python3.7 and torch 1.5. It seems to be package version problem, could you please list all your package versions? Tx

xinjli commented 3 years ago

Hi,

Thanks for reporting the issue! I am using python 3.6 and torch 1.6, but did not see this error before.

It looks that it is a float/double type issue, somehow you get the double (I tested on my local env, and I got float) I just updated the code to explicit cast double to float in the model.

Can you try updating your allosaurus version? It should be working now.