vanzytay / pytorch_sentiment_rnn

Example Recurrent Neural Networks for Sentiment Analysis (Aspect-Based) on SemEval 2014
76 stars 14 forks source link

ATT-RNN RuntimeError: invalid argument 0: Tensors must have same number of dimensions: got 2 and 3 at /opt/conda/conda-bld/pytorch_1518238409320/work/torch/lib/THC/generic/THCTensorMath.cu:102 #7

Open monajalal opened 6 years ago

monajalal commented 6 years ago

How would you run the code for ATT-RNN model?

python train.py --batch-size 20 --rnn_type GRU --cuda --gpu 1 --lr 0.0001 --mdl ATT-RNN --clip_norm 1 --opt Adam --epochs 50/scratch/sjn-p2/anaconda/anaconda2/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Using TensorFlow backend.
There are 2 CUDA devices
Setting torch GPU to 1
Using device:1 
Stored Environment:['term_len', 'word_index', 'glove', 'max_len', 'train', 'dev', 'test', 'index_word']
Loaded environment
Creating Model...
Setting Pretrained Embeddings
Initialized GRU model
Starting training
Namespace(aggregation='mean', attention_width=5, batch_size=20, clip_norm=1, cuda=True, dataset='Restaurants', dev=1, dropout_prob=0.5, embedding_size=300, epochs=50, eval=1, gpu=1, hidden_layer_size=300, l2_reg=0.0, learn_rate=0.0001, log=1, maxlen=0, mode='term', model_type='ATT-RNN', opt='Adam', pretrained=1, rnn_direction='uni', rnn_layers=1, rnn_size=300, rnn_type='GRU', seed=1111, term_model='mean', toy=False, trainable=1)
========================================================================
/scratch2/debate_tweets/sentiment/pytorch_sentiment_rnn/models/attention.py:50: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
  a = self.softmax(a)
Traceback (most recent call last):
  File "train.py", line 345, in <module>
    exp.train()
  File "train.py", line 328, in train
    loss = self.train_batch(i)
  File "train.py", line 300, in train_batch
    output, hidden = self.mdl(sentence, hidden)
  File "/scratch/sjn-p2/anaconda/anaconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 357, in __call__
    result = self.forward(*input, **kwargs)
  File "/scratch2/debate_tweets/sentiment/pytorch_sentiment_rnn/models/rnn.py", line 44, in forward
    output = self.AttentionLayer(output, attention_width=self.args.attention_width)
  File "/scratch/sjn-p2/anaconda/anaconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 357, in __call__
    result = self.forward(*input, **kwargs)
  File "/scratch2/debate_tweets/sentiment/pytorch_sentiment_rnn/models/attention.py", line 67, in forward
    results = torch.cat((results,output),0)
RuntimeError: invalid argument 0: Tensors must have same number of dimensions: got 2 and 3 at /opt/conda/conda-bld/pytorch_1518238409320/work/torch/lib/THC/generic/THCTensorMath.cu:102