salesforce / awd-lstm-lm

LSTM and QRNN Language Model Toolkit for PyTorch
BSD 3-Clause "New" or "Revised" License
1.96k stars 487 forks source link

AttributeError: 'LSTM' object has no attribute 'weight_hh_l0' #119

Closed owaski closed 4 years ago

owaski commented 4 years ago

I'm using pytorch 1.4.0 and cuda 10.1 now. When I run

python main.py --batch_size 20 --data data/penn --dropouti 0.4 --dropouth 0.25 --seed 141 --epoch 500 --save PTB.pt

I get following error message

Producing dataset...
Applying weight drop of 0.5 to weight_hh_l0
Applying weight drop of 0.5 to weight_hh_l0
Applying weight drop of 0.5 to weight_hh_l0
[WeightDrop(
  (module): LSTM(400, 1150)
), WeightDrop(
  (module): LSTM(1150, 1150)
), WeightDrop(
  (module): LSTM(1150, 400)
)]
Using []
Traceback (most recent call last):
  File "main.py", line 144, in <module>
    model = model.cuda()
  File "/data/scratch/owaski/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 304, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/data/scratch/owaski/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 201, in _apply
    module._apply(fn)
  File "/data/scratch/owaski/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 201, in _apply
    module._apply(fn)
  File "/data/scratch/owaski/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 201, in _apply
    module._apply(fn)
  File "/data/scratch/owaski/anaconda3/lib/python3.7/site-packages/torch/nn/modules/rnn.py", line 137, in _apply
    self._flat_weights = [getattr(self, weight) for weight in self._flat_weights_names]
  File "/data/scratch/owaski/anaconda3/lib/python3.7/site-packages/torch/nn/modules/rnn.py", line 137, in <listcomp>
    self._flat_weights = [getattr(self, weight) for weight in self._flat_weights_names]
  File "/data/scratch/owaski/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 576, in __getattr__
    type(self).__name__, name))
AttributeError: 'LSTM' object has no attribute 'weight_hh_l0'

I guess that's a problem with newer version of pytorch. Can someone tell me how to fix this?

owaski commented 4 years ago

Updating to pytorch 1.5.0 solves this issue.