TencentAILabHealthcare / scPROTEIN

Apache License 2.0
44 stars 8 forks source link

tutorial nb #1 mat1 and mat2 shapes cannot be multiplied #5

Open jessegmeyerlab opened 5 months ago

jessegmeyerlab commented 5 months ago

I'm trying to run scPROTEIN on my data using the tutorial notebook and getting this error at the model building and training step:

RuntimeError                              Traceback (most recent call last)
Cell In[15], line 3
      1 model = peptide_CNN(num_amino_acid, args.max_pool_size, args.hidden_dim, 2*num_cells, args.conv_layers, args.dropout_rate, args.kernel_nums, args.kernel_size).to(device)
      2 scPROTEIN_stage1 = scPROTEIN_stage1_learning(model, peptide_onehot_padding, Y_label,args.learning_rate, args.weight_decay, args.split_percentage, args.num_epochs, args.batch_size)
----> 3 scPROTEIN_stage1.train()

File ~\AppData\Roaming\Python\Python311\site-packages\scprotein\peptide_uncertainty_estimation\multi_task_heteroscedastic_regression_model.py:93, in scPROTEIN_stage1_learning.train(self)
     91 loss = 0.
     92 optimizer.zero_grad()
---> 93 y_predict = self.model(batch_x)
     95 for i in range(0,2*num_cells,2):
     96     loss_cell = regression_loss(batch_y[:,int(i/2)], y_predict[:,i:i+2])

File ~\AppData\Roaming\Python\Python311\site-packages\torch\nn\modules\module.py:1511, in Module._wrapped_call_impl(self, *args, **kwargs)
   1509     return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
   1510 else:
-> 1511     return self._call_impl(*args, **kwargs)

File ~\AppData\Roaming\Python\Python311\site-packages\torch\nn\modules\module.py:1520, in Module._call_impl(self, *args, **kwargs)
   1515 # If we don't have any hooks, we want to skip the rest of the logic in
   1516 # this function, and just call forward.
   1517 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1518         or _global_backward_pre_hooks or _global_backward_hooks
   1519         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1520     return forward_call(*args, **kwargs)
   1522 try:
   1523     result = None

File ~\AppData\Roaming\Python\Python311\site-packages\scprotein\peptide_uncertainty_estimation\multi_task_heteroscedastic_regression_model.py:50, in peptide_CNN.forward(self, x)
     48 x = torch.flatten(x, start_dim=1, end_dim=-1)
     49 x = self.dropout(x)
---> 50 x = self.fc1(x)
     51 x = self.fc2(x)
     52 return x

File ~\AppData\Roaming\Python\Python311\site-packages\torch\nn\modules\module.py:1511, in Module._wrapped_call_impl(self, *args, **kwargs)
   1509     return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
   1510 else:
-> 1511     return self._call_impl(*args, **kwargs)

File ~\AppData\Roaming\Python\Python311\site-packages\torch\nn\modules\module.py:1520, in Module._call_impl(self, *args, **kwargs)
   1515 # If we don't have any hooks, we want to skip the rest of the logic in
   1516 # this function, and just call forward.
   1517 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1518         or _global_backward_pre_hooks or _global_backward_hooks
   1519         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1520     return forward_call(*args, **kwargs)
   1522 try:
   1523     result = None

File ~\AppData\Roaming\Python\Python311\site-packages\torch\nn\modules\linear.py:116, in Linear.forward(self, input)
    115 def forward(self, input: Tensor) -> Tensor:
--> 116     return F.linear(input, self.weight, self.bias)

RuntimeError: mat1 and mat2 shapes cannot be multiplied (256x4700 and 3100x3000)
jessegmeyerlab commented 5 months ago

Here are the first 300 rows of my data as an example - in case it is relevant, I made up the charge since I don't have the true value, and noticed the code wants a leading '_' for the peptide string so that is why I added it.

pep_quant_mapped_subset.csv