Closed Elii-hyy closed 6 days ago
Thanks for the comment!
However, it was a size mismatch error when performing the multiplication in attention, I cannot help without the specific setting of yours. Perhaps you should check your configurations first.
Here's a clue that may help: when the bidirectional
options are set as True in nn.GRU()
, the hidden states will double since it contains information from both directions(i.e., forwards and backwards). So the 2nd dimension of variable hiddens
, as shown in this error message, will be doubled. The error message says that a has a size of 200 in dimension 2 while the other one is 100, I think this could be the reason.
If anything goes wrong, please let me know.
我在训练的时候出现了如下错误,不知道如何纠正。
回溯(最近一次调用最后): 文件“/Users/heyingying/PycharmProjects/PLELog/approaches/PLELog.py”,第255行, 损失= plelog.forward(tinst.inputs,tinst.targets) 文件“/Users/heyingying /PycharmProjects/PLELog/approaches/PLELog.py”,第 56 行,前向 tag_logits = self.model(inputs) 文件“/Users/heyingying/opt/anaconda3/envs/pytorch/lib/python3.10/site-packages/ torch/nn/modules/module.py”,第 1194 行,在 _call_impl returnforward_call(*input, *kwargs) 文件“/Users/heyingying/PycharmProjects/PLELog/models/gru.py”,第 71 行,在forward 中 表示=hiddenssent_probs 运行时错误:张量 a (200) 的大小必须与非单一维度 2 处的张量 b (100) 的大小匹配
May I ask if this problem has been solved?I have also encountered the same problem.
When I was training, the following error occurred,and I don't know how to correct it。
Traceback (most recent call last): File "/Users/heyingying/PycharmProjects/PLELog/approaches/PLELog.py", line 255, in
loss = plelog.forward(tinst.inputs, tinst.targets)
File "/Users/heyingying/PycharmProjects/PLELog/approaches/PLELog.py", line 56, in forward
tag_logits = self.model(inputs)
File "/Users/heyingying/opt/anaconda3/envs/pytorch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, *kwargs)
File "/Users/heyingying/PycharmProjects/PLELog/models/gru.py", line 71, in forward
represents = hiddens sent_probs
RuntimeError: The size of tensor a (200) must match the size of tensor b (100) at non-singleton dimension 2