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

AttributeError: 'Sequential' object has no attribute 'model' #1

Open
SnowWindSaveYou opened this issue Sep 3, 2018 · 2 comments
Open

Comments

@SnowWindSaveYou
Copy link

SnowWindSaveYou commented Sep 3, 2018

Hi, use the models download from link in notebook is fine, but when i try to use the model trained from pytorch-CycleGAN-and-pix2pix, it will shows this error:

Traceback (most recent call last):
  File "test.py", line 56, in <module>
    netG = load_model('./models/facades_label2photo/test_G.pth')

  File "test.py", line 47, in load_model
    __patch_instance_norm_state_dict(state_dict, net_g, key.split('.') )

  File "test.py", line 36, in __patch_instance_norm_state_dict
    __patch_instance_norm_state_dict(state_dict, getattr(module, key), keys, i + 1)

  File "test.py", line 36, in __patch_instance_norm_state_dict
    __patch_instance_norm_state_dict(state_dict, getattr(module, key), keys, i + 1)

  File "/Users/.../miniconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __getattr__

type(self).__name__, name))
AttributeError: 'Sequential' object has no attribute 'model' 

After debug, i see the keys of them is different

Models download from link in jupyter have very clear structure like['model','1','something']
But in the model of my-self is a lot of like ['model','model','1','model','3','something']

Compare:

Keys must have

 Missing key(s) in state_dict: "model.1.weight", "model.1.bias", "model.2.running_mean", 
"model.2.running_var", "model.4.weight", "model.4.bias", "model.5.running_mean", 
"model.5.running_var", "model.7.weight", "model.7.bias", "model.8.running_mean", 
"model.8.running_var", "model.10.conv_block.1.weight", "model.10.conv_block.1.bias", 
"model.10.conv_block.2.running_mean", "model.10.conv_block.2.running_var", 
"model.10.conv_block.5.weight", "model.10.conv_block.5.bias", "model.10.conv_block.6.running_mean", "model.10.conv_block.6.running_var", "model.11.conv_block.1.weight", "model.11.conv_block.1.bias", "model.11.conv_block.2.running_mean", "model.11.conv_block.2.running_var", "model.11.conv_block.5.weight", "model.11.conv_block.5.bias", "model.11.conv_block.6.running_mean", "model.11.conv_block.6.running_var", "model.12.conv_block.1.weight", "model.12.conv_block.1.bias", "model.12.conv_block.2.running_mean", "model.12.conv_block.2.running_var", "model.12.conv_block.5.weight", "model.12.conv_block.5.bias", "model.12.conv_block.6.running_mean", "model.12.conv_block.6.running_var", "model.13.conv_block.1.weight", "model.13.conv_block.1.bias", "model.13.conv_block.2.running_mean", "model.13.conv_block.2.running_var", "model.13.conv_block.5.weight", "model.13.conv_block.5.bias", "model.13.conv_block.6.running_mean", "model.13.conv_block.6.running_var", "model.14.conv_block.1.weight", "model.14.conv_block.1.bias", "model.14.conv_block.2.running_mean", "model.14.conv_block.2.running_var", "model.14.conv_block.5.weight", "model.14.conv_block.5.bias", "model.14.conv_block.6.running_mean", "model.14.conv_block.6.running_var", "model.15.conv_block.1.weight", "model.15.conv_block.1.bias", "model.15.conv_block.2.running_mean", "model.15.conv_block.2.running_var", "model.15.conv_block.5.weight", "model.15.conv_block.5.bias", "model.15.conv_block.6.running_mean", "model.15.conv_block.6.running_var", "model.16.conv_block.1.weight", "model.16.conv_block.1.bias", "model.16.conv_block.2.running_mean", "model.16.conv_block.2.running_var", "model.16.conv_block.5.weight", "model.16.conv_block.5.bias", "model.16.conv_block.6.running_mean", "model.16.conv_block.6.running_var", "model.17.conv_block.1.weight", "model.17.conv_block.1.bias", 
"model.17.conv_block.2.running_mean", "model.17.conv_block.2.running_var", 
"model.17.conv_block.5.weight", "model.17.conv_block.5.bias", "model.17.conv_block.6.running_mean", 
"model.17.conv_block.6.running_var", "model.18.conv_block.1.weight", "model.18.conv_block.1.bias", 
"model.18.conv_block.2.running_mean", "model.18.conv_block.2.running_var", 
"model.18.conv_block.5.weight", "model.18.conv_block.5.bias", "model.18.conv_block.6.running_mean",
 "model.18.conv_block.6.running_var", "model.19.weight", "model.19.bias", "model.20.running_mean", 
"model.20.running_var", "model.22.weight", "model.22.bias", "model.23.running_mean", 
"model.23.running_var", "model.26.weight", "model.26.bias".

My one

Unexpected key(s) in state_dict: "model.model.0.weight", "model.model.1.model.1.weight", 
"model.model.1.model.2.weight", "model.model.1.model.2.bias", 
"model.model.1.model.2.running_mean", "model.model.1.model.2.running_var", 
"model.model.1.model.3.model.1.weight", "model.model.1.model.3.model.2.weight",
 "model.model.1.model.3.model.2.bias", "model.model.1.model.3.model.2.running_mean", 
"model.model.1.model.3.model.2.running_var", "model.model.1.model.3.model.3.model.1.weight", 
"model.model.1.model.3.model.3.model.2.weight", "model.model.1.model.3.model.3.model.2.bias", 
"model.model.1.model.3.model.3.model.2.running_mean", 
"model.model.1.model.3.model.3.model.2.running_var", 
"model.model.1.model.3.model.3.model.3.model.1.weight", 
"model.model.1.model.3.model.3.model.3.model.2.weight", 
"model.model.1.model.3.model.3.model.3.model.2.bias", 
"model.model.1.model.3.model.3.model.3.model.2.running_mean", "model.model.1.model.3.model.3.model.3.model.2.running_var", "model.model.1.model.3.model.3.model.3.model.3.model.1.weight", "model.model.1.model.3.model.3.model.3.model.3.model.2.weight", "model.model.1.model.3.model.3.model.3.model.3.model.2.bias", "model.model.1.model.3.model.3.model.3.model.3.model.2.running_mean", "model.model.1.model.3.model.3.model.3.model.3.model.2.running_var", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.1.weight", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.2.weight", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.2.bias", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.2.running_mean", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.2.running_var", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.3.model.1.weight", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.3.model.3.weight", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.3.model.4.weight", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.3.model.4.bias", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.3.model.4.running_mean", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.3.model.4.running_var", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.3.model.4.num_batches_tracked", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.5.weight", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.6.weight", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.6.bias", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.6.running_mean", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.6.running_var", "model.model.1.model.3.model.3.model.3.model.3.model.3.model.6.num_batches_tracked", "model.model.1.model.3.model.3.model.3.model.3.model.5.weight", "model.model.1.model.3.model.3.model.3.model.3.model.6.weight", "model.model.1.model.3.model.3.model.3.model.3.model.6.bias", "model.model.1.model.3.model.3.model.3.model.3.model.6.running_mean", "model.model.1.model.3.model.3.model.3.model.3.model.6.running_var", "model.model.1.model.3.model.3.model.3.model.3.model.6.num_batches_tracked", "model.model.1.model.3.model.3.model.3.model.5.weight", "model.model.1.model.3.model.3.model.3.model.6.weight", "model.model.1.model.3.model.3.model.3.model.6.bias", "model.model.1.model.3.model.3.model.3.model.6.running_mean", "model.model.1.model.3.model.3.model.3.model.6.running_var", "model.model.1.model.3.model.3.model.3.model.6.num_batches_tracked", "model.model.1.model.3.model.3.model.5.weight", "model.model.1.model.3.model.3.model.6.weight", "model.model.1.model.3.model.3.model.6.bias", "model.model.1.model.3.model.3.model.6.running_mean", "model.model.1.model.3.model.3.model.6.running_var", "model.model.1.model.3.model.3.model.6.num_batches_tracked", 
"model.model.1.model.3.model.5.weight", "model.model.1.model.3.model.6.weight", 
"model.model.1.model.3.model.6.bias", "model.model.1.model.3.model.6.running_mean", 
"model.model.1.model.3.model.6.running_var", 
"model.model.1.model.3.model.6.num_batches_tracked", "model.model.1.model.5.weight", 
"model.model.1.model.6.weight", "model.model.1.model.6.bias", 
"model.model.1.model.6.running_mean", "model.model.1.model.6.running_var", 
"model.model.1.model.6.num_batches_tracked", "model.model.3.weight", "model.model.3.bias".

@SnowWindSaveYou
Copy link
Author

Found problem...
because my one is actually pix2pix model

Because i can run the model download from link, and they have same name, i suddenly not discover this difference (:з」∠)

@junjy007
Copy link
Owner

junjy007 commented Sep 3, 2018 via email

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

2 participants