LAL-Parser
LAL-Parser copied to clipboard
RuntimeError: mat1 and mat2 shapes cannot be multiplied
Hi, thank you for your work.
I tried to your code with train data and it worked fine. But when I changed to other kind of data, or even if I used dev data instead of train data. It got RuntimeError: mat1 and mat2 shapes cannot be multiplied
I also refactor some parts of code, but it still only works on your train data, not with others as I mentioned above.
Hope you could give me some glues to overcome this problem.
Full log here
File "/Users/Desktop/cldp/HPSG-Tutorial/HPSG/model/chart_parser.py", line 346, in label_scores_from_annotations
label_scores_chart = self.f_label(span_features)
File "/Users/Desktop/cldp/HPSG-Tutorial/venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/Users/Desktop/cldp/HPSG-Tutorial/venv/lib/python3.8/site-packages/torch/nn/modules/container.py", line 119, in forward
input = module(input)
File "/Users/Desktop/cldp/HPSG-Tutorial/venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/Users/Desktop/cldp/HPSG-Tutorial/venv/lib/python3.8/site-packages/torch/nn/modules/linear.py", line 94, in forward
return F.linear(input, self.weight, self.bias)
File "/Users/Desktop/cldp/HPSG-Tutorial/venv/lib/python3.8/site-packages/torch/nn/functional.py", line 1753, in linear
return torch._C._nn.linear(input, weight, bias)
RuntimeError: mat1 and mat2 shapes cannot be multiplied (9x6144 and 6016x250)
Thank you.
Recently, I have found a way to work around above problem. The solution is to change lal_combine_as_self
param to True
(I made this change in main.py
file at line 81).
Why I know this? When I debugged code at the line number 1379 in KM_parser.py
file, I tried to use hparams.d_model
and the error did not occur.
annotation_dim = ((label_vocab.size - 2) * self.lal_d_proj) if (self.use_lal and not self.lal_combine_as_self) else hparams.d_model
But for me, I do not like this solution because it decreases accuracy so much, at least in my task. So use it carefully