Skip to content

Meet problem when load model dict #10

@Huang-yihao

Description

@Huang-yihao

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions