You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After running the tutorial code without issue, I want to add the meta information "peptide charge" as the additional feature in the model. I found there is the existing class Encoder_26AA_Mod_Charge_CNN_LSTM_AttnSum in building_block.py, so I just tried modifying the class RT_LSTM_Module in the tutorial code:
I also added a line in the class RT_ModelInterface function _get_features_from_batch_df:
charges = torch.Tensor(batch_df['charge'].values)
Then, when I try to train the new model, it gives the below error:
File ~\alphapeptdeep\peptdeep\model\model_interface.py:493, in ModelInterface.train(self, precursor_df, batch_size, epoch, warmup_epoch, lr, verbose, verbose_each_epoch, **kwargs)
491 for epoch in range(epoch):
492 if self.fixed_sequence_len == 0:
--> 493 batch_cost = self._train_one_epoch(
494 precursor_df, epoch,
495 batch_size, verbose_each_epoch,
496 **kwargs
497 )
498 else:
499 batch_cost = self._train_one_epoch_by_padding_zeros(
500 precursor_df, epoch,
501 batch_size, verbose_each_epoch,
502 **kwargs
503 )
File ~\alphapeptdeep\peptdeep\model\model_interface.py:822, in ModelInterface._train_one_epoch(self, precursor_df, epoch, batch_size, verbose_each_epoch, **kwargs)
817 features = self._get_features_from_batch_df(
818 batch_df, **kwargs
819 )
820 if isinstance(features, tuple):
821 batch_cost.append(
--> 822 self._train_one_batch(targets, *features)
823 )
824 else:
825 batch_cost.append(
826 self._train_one_batch(targets, features)
827 )
File ~\alphapeptdeep\peptdeep\model\model_interface.py:842, in ModelInterface._train_one_batch(self, targets, *features)
840 """Training for a mini batch"""
841 self.optimizer.zero_grad()
--> 842 predicts = self.model(*features)
843 cost = self.loss_func(predicts, targets)
844 cost.backward()
File C:\ProgramData\anaconda3\envs\peptdeep\lib\site-packages\torch\nn\modules\module.py:1553, in Module._wrapped_call_impl(self, *args, **kwargs)
1551 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1552 else:
-> 1553 return self._call_impl(*args, **kwargs)
File C:\ProgramData\anaconda3\envs\peptdeep\lib\site-packages\torch\nn\modules\module.py:1562, in Module._call_impl(self, *args, **kwargs)
1557 # If we don't have any hooks, we want to skip the rest of the logic in
1558 # this function, and just call forward.
1559 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1560 or _global_backward_pre_hooks or _global_backward_hooks
1561 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1562 return forward_call(*args, **kwargs)
1564 try:
1565 result = None
TypeError: forward() missing 1 required positional argument: 'charges'
I thought I already put in the 'charges' argument and couldn't figure out how to fix this problem. Hope you would please help take a look and teach me more about meta embedding in AlphaPeptDeep. Many thanks!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I am a newbie of AlphaPeptDeep and Torch in general, and I am trying to learn through your tutorial https://alphapeptdeep.readthedocs.io/en/latest/nbs/tutorial_building_rt_model.html in Jupyter Notebook.
After running the tutorial code without issue, I want to add the meta information "peptide charge" as the additional feature in the model. I found there is the existing class Encoder_26AA_Mod_Charge_CNN_LSTM_AttnSum in building_block.py, so I just tried modifying the class RT_LSTM_Module in the tutorial code:
I also added a line in the class RT_ModelInterface function _get_features_from_batch_df:
Then, when I try to train the new model, it gives the below error:
I thought I already put in the 'charges' argument and couldn't figure out how to fix this problem. Hope you would please help take a look and teach me more about meta embedding in AlphaPeptDeep. Many thanks!
Beta Was this translation helpful? Give feedback.
All reactions