zht-code / MUSCLE

Multi-view and multi-scale attentional feature fusion for microRNA-disease associations prediction
2 stars 0 forks source link

RuntimeError: mat1 and mat2 shapes cannot be multiplied (24297x3604 and 3556x1024) #1

Open kun2001github opened 6 months ago

kun2001github commented 6 months ago

Hi~ zht-code, I encountered the following error when copying your project, can you tell me how to solve it

**(muscle-py38) root@f1e2ff086eb1:~/MUSCLE-main# python ./src/train.py**
Traceback (most recent call last):
  File "./src/train.py", line 144, in <module>
    train_score, test_score = model(dataset, tran_sample_index, test_sample_index, device)
  File "/root/miniconda3/envs/muscle-py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/root/MUSCLE-main/src/model.py", line 160, in forward
    train_score = self.mlp(train_emb)
  File "/root/miniconda3/envs/muscle-py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/root/miniconda3/envs/muscle-py38/lib/python3.8/site-packages/torch/nn/modules/container.py", line 141, in forward
    input = module(input)
  File "/root/miniconda3/envs/muscle-py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/root/miniconda3/envs/muscle-py38/lib/python3.8/site-packages/torch/nn/modules/linear.py", line 103, in forward
    return F.linear(input, self.weight, self.bias)
  File "/root/miniconda3/envs/muscle-py38/lib/python3.8/site-packages/torch/nn/functional.py", line 1848, in linear
    return torch._C._nn.linear(input, weight, bias)
**RuntimeError: mat1 and mat2 shapes cannot be multiplied (24297x3604 and 3556x1024)**

My environment python 3.8.19 pytorch 1.10.1 py3.8_cuda11.3_cudnn8.2.0_0 torch-geometric 2.5.2 scipy 1.5.4 numpy 1.24.4 scikit-learn 1.3.2 pandas 1.1.5 matplotlib 3.3.4 networkx 2.5.1

My cuda version Cuda compilation tools, release 11.3, V11.3.109

zixiaojin66 commented 5 months ago

The input train_emb to self.mlp doesn’t have the expected number of features, so you would need to change the in_features of the first nn. Linear layer in self.mlp to 3604.

kun2001github commented 4 months ago

The input train_emb to self.mlp doesn’t have the expected number of features, so you would need to change the in_features of the first nn. Linear layer in self.mlp to 3604.

Ok, thank you very much for your answer