castorini / hedwig

PyTorch deep learning models for document classification
Apache License 2.0
591 stars 125 forks source link

AttributeError: 'Tensor' object has no attribute 'uniform' #40

Open PiercarloSlavazza opened 4 years ago

PiercarloSlavazza commented 4 years ago

Env

Everything installed as specified in the radme

Error

When executing:

python -m models.han --dataset Reuters --mode rand --batch-size 32 --lr 0.01 --epochs 30 --seed 3435

I get:

(castor) PS C:\Users\piercarlo\Documents\workspace\personal\hedwig\hedwig> python -m models.han --dataset Reuters --mode rand --batch-size 32 --lr 0.01 --epochs 30 --seed 3435
Note: You are using GPU for training
Dataset: Reuters
No. of target classes: 90
No. of train instances 5827
No. of dev instances 1943
No. of test instances 3019
Traceback (most recent call last):
  File "C:\tools\Anaconda3\envs\castor\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\tools\Anaconda3\envs\castor\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\piercarlo\Documents\workspace\personal\hedwig\hedwig\models\han\__main__.py", line 117, in <module>
    model = HAN(config)
  File "C:\Users\piercarlo\Documents\workspace\personal\hedwig\hedwig\models\han\model.py", line 13, in __init__
    self.word_attention_rnn = WordLevelRNN(config)
  File "C:\Users\piercarlo\Documents\workspace\personal\hedwig\hedwig\models\han\word_level_rnn.py", line 15, in __init__
    rand_embed_init = torch.Tensor(words_num, words_dim).uniform(-0.25, 0.25)
AttributeError: 'Tensor' object has no attribute 'uniform'
PiercarloSlavazza commented 4 years ago

Additional note: executing the same command with --mode static does not give the error.