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

runtime error with pytorch 0.4.0 #277

Closed
xhzhao opened this issue Apr 17, 2018 · 2 comments
Closed

runtime error with pytorch 0.4.0 #277

xhzhao opened this issue Apr 17, 2018 · 2 comments

Comments

@xhzhao
Copy link

xhzhao commented Apr 17, 2018

i came across this error with pytorch 0.4.0a0+0f198fa:

Epoch: [1][19/29] Time 9.658 (6.595) Data 0.022 (0.040) Loss 65.1772 (79.3325)
Epoch: [1][20/29] Time 10.012 (6.766) Data 0.024 (0.040) Loss 76.3577 (79.1838)
Epoch: [1][21/29] Time 10.893 (6.962) Data 0.019 (0.039) Loss 76.3393 (79.0483)
Epoch: [1][22/29] Time 11.721 (7.179) Data 0.020 (0.038) Loss 68.5335 (78.5704)
Epoch: [1][23/29] Time 13.135 (7.438) Data 0.020 (0.037) Loss 79.9024 (78.6283)
Epoch: [1][24/29] Time 13.349 (7.684) Data 0.039 (0.037) Loss 69.2027 (78.2355)
Epoch: [1][25/29] Time 13.621 (7.921) Data 0.023 (0.037) Loss 73.2235 (78.0351)
Epoch: [1][26/29] Time 14.609 (8.179) Data 0.038 (0.037) Loss 63.1697 (77.4633)
Epoch: [1][27/29] Time 17.431 (8.521) Data 0.025 (0.036) Loss 77.6363 (77.4697)
Epoch: [1][28/29] Time 26.266 (9.155) Data 0.024 (0.036) Loss 75.8170 (77.4107)
Epoch: [1][29/29] Time 5.676 (9.035) Data 0.027 (0.035) Loss 118.7269 (77.4568)
Training Summary Epoch: [1] Time taken (s): 262 Average Loss 78.835
0%| | 0/5 [00:00<?, ?it/s]train.py:344: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
inputs = Variable(inputs, volatile=True)
check, i = 0
check, sequence[i] =
0
[torch.LongTensor of size ()]

Traceback (most recent call last):
File "train.py", line 360, in
decoded_output, _ = decoder.decode(out.data, sizes)
File "/home/zhaoxiao/test/deepspeech.pytorch-latest/decoder.py", line 199, in decode
remove_repetitions=True, return_offsets=True)
File "/home/zhaoxiao/test/deepspeech.pytorch-latest/decoder.py", line 156, in convert_to_strings
string, string_offsets = self.process_string(sequences[x], seq_len, remove_repetitions)
File "/home/zhaoxiao/test/deepspeech.pytorch-latest/decoder.py", line 172, in process_string
char = self.int_to_char[sequence[i]]
KeyError:
0
[torch.LongTensor of size ()]

it seems that the sequence[i] is not a int but a tensor.

@ryanleary
Copy link
Collaborator

PyTorch 0.4 is still unstable and therefore unsupported at this time. The error you're seeing is that 0.4 introduces 0-dimensional tensors (ie support for scalar values) when in previous versions the above indexing would return a native Python type. You can probably replace the sequence[i] with sequence[i].item() and it'll probably work.

No guarantees you don't run into other issues with 0.4. Lots of breaking changes.

@xhzhao
Copy link
Author

xhzhao commented Apr 18, 2018

thanks very much

@xhzhao xhzhao closed this as completed Apr 18, 2018
tsaoyu added a commit to tsaoyu/RL-Adventure that referenced this issue Jul 16, 2018
Trying to address two issues:
- return `action` as an item to fix runtime error
 ```
 UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
 ```
may related to: SeanNaren/deepspeech.pytorch#277

- change number of actions from global to a local one which I believe that was your intention
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