songyouwei / ABSA-PyTorch

Aspect Based Sentiment Analysis, PyTorch Implementations. 基于方面的情感分析,使用PyTorch实现。
MIT License
2.03k stars 528 forks source link

ValueError: expected sequence of length 80 at dim 1 (got 81) #114

Open paulachocron opened 4 years ago

paulachocron commented 4 years ago

Hello,

I'm getting the following error when trying to execute the models RAM, TNET, and MGAN. For example, in mgan I get:

  File "/Users/paulachocron/Workspace/ABSA-PyTorch/models/mgan.py", line 38, in weight_matrix
    weight = torch.tensor(weight)
ValueError: expected sequence of length 80 at dim 1 (got 81)

And in RAM:

  File "/Users/paulachocron/Workspace/ABSA-PyTorch/models/ram.py", line 33, in locationed_memory
    u = torch.tensor(u).to(self.opt.device).unsqueeze(2)
ValueError: expected sequence of length 81 at dim 1 (got 80)

80 is the default max_len.

Any ideas?

Thanks,

Paula

songyouwei commented 4 years ago

Are you using the default configuration? Please provide your pytorch version and training log.

GeneZC commented 4 years ago

How about setting max len to 83 instead ?

zhangyikaii commented 4 years ago

Hello!

You can modify the code according to this issue I raised to avoid this error:

117