Open QUEST2179 opened 2 months ago
Hi, I saved the model parameters on the CPU. If you need to perform inference on CUDA, you can first instantiate the model and then load the parameters:
from EpiScan.models.deep_ppi import DeepPPI modelCon_path = './Seq_final.pth' modelCon = DeepPPI(50, 5) modelCon.load_state_dict(torch.load(modelCon_path)) if use_cuda: modelCon.cuda()
After instantiating the model, I ran into two additional issues:
TypeError: unhashable type: 'Series'
when defining p0Con.
I found a workaround but the fixes were very extensive so I'm wondering if you have a more straightforward fix @gzBiomedical
Additionally, I ran into a class error when trying to run the map_predict() function on DeepPPI. Can you suggest an approach for calling this function?
After instantiating the model, I ran into two additional issues:
TypeError: unhashable type: 'Series'
when defining p0Con. I found a workaround but the fixes were very extensive so I'm wondering if you have a more straightforward fix @gzBiomedicalAdditionally, I ran into a class error when trying to run the map_predict() function on DeepPPI. Can you suggest an approach for calling this function?
I wrote a demo in the commands directory: [demo_test.py], it should be worked now
I tested out the demo with the updated repo and I'm still running into an error with the map_predict() function.
setStorage: sizes [1, 46, 27], strides [46, 1, 0], storage offset 0, and itemsize 4 requiring a storage size of 184 are out of bounds for storage of size 0
Any suggestions?
Here's the full error:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/tmp/ipykernel_179412/3899989061.py in <module>
----> 1 cmCon,_ = modelCon.map_predict(p0Con, p1Con,test_dfCon[3][indedx],index_cdrlist)
~/epitope_predictions/EpiScan_2/EpiScan/EpiScan/models/interaction_sep.py in map_predict(self, z0, z1, catsite, cdrindex)
110 def map_predict(self, z0, z1,catsite,cdrindex):
111
--> 112 C = self.cpred(z0, z1,catsite,cdrindex)
113
114 if self.do_w:
~/epitope_predictions/EpiScan_2/EpiScan/EpiScan/models/interaction_sep.py in cpred(self, z0, z1, catsite, cdrindex)
104
105
--> 106 B = self.contact.cmap(e0, e1,catsite,cdrindex)
107 C = self.contact.predict(B)
108 return C
~/epitope_predictions/EpiScan_2/EpiScan/EpiScan/models/contact_sep.py in cmap(self, z0, z1, catsite, cdrindex)
165 def cmap(self, z0, z1, catsite,cdrindex):
166
--> 167 C = self.hidden(z0, z1, catsite,cdrindex)
168 return C
169
~/anaconda3/envs/episcan/lib/python3.7/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
1108 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1109 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1110 return forward_call(*input, **kwargs)
1111 # Do not call functions when jit is used
1112 full_backward_hooks, non_full_backward_hooks = [], []
~/epitope_predictions/EpiScan_2/EpiScan/EpiScan/models/contact_sep.py in forward(self, z0, z1, catsite, cdrindex)
94 Z1Hcdr = torch.gather(z1H, 2, cdrHind)
95 Z1Hnotcdr = torch.gather(z1H, 2, notcdrHind)
---> 96 Z1Lcdr = torch.gather(z1L, 2, cdrLind)
97 Z1Lnotcdr = torch.gather(z1L, 2, notcdrLind)
98
RuntimeError: setStorage: sizes [1, 46, 27], strides [46, 1, 0], storage offset 0, and itemsize 4 requiring a storage size of 184 are out of bounds for storage of size 0
I tested out the demo with the updated repo and I'm still running into an error with the map_predict() function.
setStorage: sizes [1, 46, 27], strides [46, 1, 0], storage offset 0, and itemsize 4 requiring a storage size of 184 are out of bounds for storage of size 0
Any suggestions?Here's the full error:
--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) /tmp/ipykernel_179412/3899989061.py in <module> ----> 1 cmCon,_ = modelCon.map_predict(p0Con, p1Con,test_dfCon[3][indedx],index_cdrlist) ~/epitope_predictions/EpiScan_2/EpiScan/EpiScan/models/interaction_sep.py in map_predict(self, z0, z1, catsite, cdrindex) 110 def map_predict(self, z0, z1,catsite,cdrindex): 111 --> 112 C = self.cpred(z0, z1,catsite,cdrindex) 113 114 if self.do_w: ~/epitope_predictions/EpiScan_2/EpiScan/EpiScan/models/interaction_sep.py in cpred(self, z0, z1, catsite, cdrindex) 104 105 --> 106 B = self.contact.cmap(e0, e1,catsite,cdrindex) 107 C = self.contact.predict(B) 108 return C ~/epitope_predictions/EpiScan_2/EpiScan/EpiScan/models/contact_sep.py in cmap(self, z0, z1, catsite, cdrindex) 165 def cmap(self, z0, z1, catsite,cdrindex): 166 --> 167 C = self.hidden(z0, z1, catsite,cdrindex) 168 return C 169 ~/anaconda3/envs/episcan/lib/python3.7/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs) 1108 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks 1109 or _global_forward_hooks or _global_forward_pre_hooks): -> 1110 return forward_call(*input, **kwargs) 1111 # Do not call functions when jit is used 1112 full_backward_hooks, non_full_backward_hooks = [], [] ~/epitope_predictions/EpiScan_2/EpiScan/EpiScan/models/contact_sep.py in forward(self, z0, z1, catsite, cdrindex) 94 Z1Hcdr = torch.gather(z1H, 2, cdrHind) 95 Z1Hnotcdr = torch.gather(z1H, 2, notcdrHind) ---> 96 Z1Lcdr = torch.gather(z1L, 2, cdrLind) 97 Z1Lnotcdr = torch.gather(z1L, 2, notcdrLind) 98 RuntimeError: setStorage: sizes [1, 46, 27], strides [46, 1, 0], storage offset 0, and itemsize 4 requiring a storage size of 184 are out of bounds for storage of size 0
This is due to a mismatch in sequence length. Re-generating DB1.h5 with DB1.fasta(updated) should fix the problem
python ./EpiScan/commands/epimapping.py --test ./dataProcess/public/public_sep_testAg.tsv --embedding ./dataProcess/public/fasta/DB1.h5 --outfile ./dataProcess/public/public_sep_testAg.out --device 0 [2024-09-13-09:50:08] Using CUDA device 0 - NVIDIA GeForce GTX 1660 Ti [2024-09-13-09:50:08] Using CUDA device 0 - NVIDIA GeForce GTX 1660 Ti Traceback (most recent call last): File "C:\Users\antibody\EpiScan-master\EpiScan\commands\epimapping.py", line 124, in
main(parser.parse_args())
File "C:\Users\antibody\EpiScan-master\EpiScan\commands\epimapping.py", line 34, in main
train_model(args, output)
File "C:\Users\antibody\EpiScan-master\EpiScan\commands\epimapping.py", line 77, in train_model
modelCon = torch.load(modelCon_path).cuda()
AttributeError: 'collections.OrderedDict' object has no attribute 'cuda'