horsepurve / DeepRTplus

Deep (Transfer) Learning for Peptide Retention Time Prediction
MIT License
49 stars 22 forks source link

inconsistent tensor size, expected tensor [1 x 736 x 8 x 16] and src [1 x 1248 x 8 x 16] to have the same number of elements #5

Open younglululu opened 6 years ago

younglululu commented 6 years ago

I am making prediction using the trained models. I used the following command:

python prediction_emb.py 100 param/dia_all_epo20_dim24_conv10/dia_all_epo20_dim24_conv10_filled.pt 10 data/mod.txt

And here is the error I encoutered which is reproducible in both python 2.7 and python 3.7, pytorch version 0.4.1

While copying the parameter named digit_capsules.route_weights, whose dimensions in the model are torch.Size([1, 736, 8, 16]) and whose dimensions in the checkpoint are torch.Size([1, 1248, 8, 16]), ... Traceback (most recent call last): File "prediction_emb.py", line 78, in obse,pred1=pred_from_model(conv1,conv1,round1model,RTtest,15) File "prediction_emb.py", line 17, in pred_from_model model.load_state_dict(torch.load(param_path)) File "/home/yanglu/anaconda2/envs/dl_env/lib/python2.7/site-packages/torch/nn/modules/module.py", line 360, in load_state_dict ownstate[name].copy(param) RuntimeError: inconsistent tensor size, expected tensor [1 x 736 x 8 x 16] and src [1 x 1248 x 8 x 16] to have the same number of elements, but got 94208 and 159744 elements respectively at /opt/conda/conda-bld/pytorch_1503966894950/work/torch/lib/TH/generic/THTensorCopy.c:86

horsepurve commented 6 years ago

Hi, because here "dia" and "mod" are two different data sets with different maximum peptide lengths (66 vs. 50), please simply change line #16 in config.py to be:

max_length = 66

And while making prediction using another trained model, just change this value to be the max peptide length in that data set (e.g. 50 in "mod" data).

Thank you.

younglululu commented 6 years ago

Dear Chunwei,

The program can run now. Thanks for the help!

Best regards, Yang Lu

On Sun, Nov 11, 2018 at 10:11 AM Chunwei Ma notifications@github.com wrote:

Hi, because here "dia" and "mod" are two different data sets with different maximum peptide length (66 vs. 50), please simply change line

16

https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_horsepurve_DeepRTplus_blob_master_config.py-23L16&d=DwMFaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=WpU5ZNHyuHh29_wmb9c4AA&m=RykoWwYV5rhfsUCOP2ptcGEOB6Q6VT3fYV5la4ESu5w&s=_REpg1E-VLRSYD0xP_KNpxxniVHXvw9M5Lj4Pu8wkoE&e= in config.py to be:

max_length = 66

And while making prediction using another trained model, just change this value to be the max peptide length in that data set (e.g. 50 in "mod" data).

Thank you.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_horsepurve_DeepRTplus_issues_5-23issuecomment-2D437691691&d=DwMFaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=WpU5ZNHyuHh29_wmb9c4AA&m=RykoWwYV5rhfsUCOP2ptcGEOB6Q6VT3fYV5la4ESu5w&s=dvBI7RnktKUqKBaQMCkJqx859igxS1P9jQsN_WfiTtA&e=, or mute the thread https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AOmuWoGFR-2DiYfTaw0V5lFUhmgGf1OSBaks5uuGhjgaJpZM4YYUEj&d=DwMFaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=WpU5ZNHyuHh29_wmb9c4AA&m=RykoWwYV5rhfsUCOP2ptcGEOB6Q6VT3fYV5la4ESu5w&s=ppj0223EspZIgl19ycI_uGO3tfbj-qP_7dmH6h90a5Y&e= .