Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error training "RuntimeError: mat1 dim 1 must match mat2 dim 0" #262

Open
nathanielhobbs opened this issue Oct 27, 2021 · 0 comments
Open

Comments

@nathanielhobbs
Copy link

When running the command
pyhon tools/train.py --cfg configs/fc.yml --id fc

I get the following traceback:
Traceback (most recent call last):

File "/scratch/nh385/self-critical.pytorch/tools/train.py", line 185, in train

model_out = dp_lw_model(fc_feats, att_feats, labels, masks, att_masks, data['gts'], torch.arange(0, len(data['gts'])), sc_flag, struc_flag, drop_worst_flag) 

File "/home/nh385/anaconda3/envs/xlinear/lib/python3.9/site-packages/torch/nn/modules/module.py", line 727, in _call_impl

result = self.forward(*input, **kwargs) 

File "/home/nh385/anaconda3/envs/xlinear/lib/python3.9/site-packages/torch/nn/parallel/data_parallel.py", line 159, in forward

return self.module(*inputs[0], **kwargs[0]) 

File "/home/nh385/anaconda3/envs/xlinear/lib/python3.9/site-packages/torch/nn/modules/module.py", line 727, in _call_impl

result = self.forward(*input, **kwargs) 

File "/scratch/nh385/self-critical.pytorch/captioning/modules/loss_wrapper.py", line 47, in forward

loss = self.crit(self.model(fc_feats, att_feats, labels[..., :-1], att_masks), labels[..., 1:], masks[..., 1:], reduction=reduction) 

File "/home/nh385/anaconda3/envs/xlinear/lib/python3.9/site-packages/torch/nn/modules/module.py", line 727, in _call_impl

result = self.forward(*input, **kwargs) 

File "/scratch/nh385/self-critical.pytorch/captioning/models/CaptionModel.py", line 33, in forward

return getattr(self, '_'+mode)(*args, **kwargs) 

File "/scratch/nh385/self-critical.pytorch/captioning/models/AttModel.py", line 136, in _forward

p_fc_feats, p_att_feats, pp_att_feats, p_att_masks = self._prepare_feature(fc_feats, att_feats, att_masks) 

File "/scratch/nh385/self-critical.pytorch/captioning/models/AttModel.py", line 943, in _prepare_feature

fc_feats = self.fc_embed(fc_feats) 

File "/home/nh385/anaconda3/envs/xlinear/lib/python3.9/site-packages/torch/nn/modules/module.py", line 727, in _call_impl

result = self.forward(*input, **kwargs) 

File "/home/nh385/anaconda3/envs/xlinear/lib/python3.9/site-packages/torch/nn/modules/linear.py", line 93, in forward

return F.linear(input, self.weight, self.bias) 

File "/home/nh385/anaconda3/envs/xlinear/lib/python3.9/site-packages/torch/nn/functional.py", line 1690, in linear

ret = torch.addmm(bias, input, weight.t()) 

RuntimeError: mat1 dim 1 must match mat2 dim 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant