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

Meet problem when load model dict #10

Open
Huang-yihao opened this issue Aug 16, 2020 · 0 comments
Open

Meet problem when load model dict #10

Huang-yihao opened this issue Aug 16, 2020 · 0 comments

Comments

@Huang-yihao
Copy link

Hello, I have met some problem with loading the dictionary of the model.

The code of mine is like this. I choose InceptionV3 model. I want to load the "inception_v3.ckpt" dictionary provided by you.
However, it failed and return an error. The error is shown below.

    input_size = [299, 299]
    block = Conv
    fwd_out = [64, 128, 256, 256, 256]
    num_fwd = [2, 3, 3, 3, 3]
    back_out = [64, 128, 256, 256]
    num_back = [2, 3, 3, 3]
    n = 1
    hard_mining = 0
    loss_norm = False
    denoise = Denoise(input_size[0], input_size[1], block, 3, fwd_out, num_fwd, back_out, num_back)
    net = Inception3(denoise)

    model_path = "inception_v3.ckpt"
    pretrain_dict = torch.load(model_path)
    state_dict = net.state_dict()
    for key in pretrain_dict.keys():
        assert state_dict.has_key(key)
        value = pretrain_dict[key]
        if not isinstance(value, torch.FloatTensor):
            value = value.data
        state_dict[key] = value

    net.load_state_dict(state_dict)

image

Could you please tell me where is the bug? The pytorch version used by me is 1.2.0.
Thank you very much!

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

1 participant