Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

size mismatch for emb.weight: copying a param with shape torch.Size([25, 20]) from checkpoint, the shape in current model is torch.Size([21, 20]). #8

Open
marcos914 opened this issue Mar 18, 2020 · 2 comments

Comments

@marcos914
Copy link

When I use the prediction_emb.py to predict rt value ,I have found some questions.How can I deal with it.
python prediction_emb.py 46 param/dia_all_epo20_dim24_conv12/dia_all_epo20_dim24_conv12_filled.pt 12 data/SCX.txt

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/renzhe/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 769, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for CapsuleNet:
size mismatch for emb.weight: copying a param with shape torch.Size([25, 20]) from checkpoint, the shape in current model is torch.Size([21, 20]).

@horsepurve
Copy link
Owner

horsepurve commented Mar 18, 2020

Could you try changing config.py from

dict_path = ''
max_length = 50

to

dict_path = 'data/mod.txt'
max_length = 66

because 66 is the max length in the "dia.txt" dataset, while 50 is for the "mod.txt" dataset, and "dict_path" means we want to include four modifications.

By the way, I guess you were using RPLC model to make predictions on SCX data, which might not be valid, since RP and SCX are different separation mechanisms...

@nasseralfadly
Copy link

I have the same problem in my model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants