Skip to content

Problem of "SAVING AND LOADING A GENERAL CHECKPOINT IN PYTORCH" #1430

@JinFish

Description

@JinFish

In chapter5-Load the general checkpoint of "SAVING AND LOADING A GENERAL CHECKPOINT IN PYTORCH":
model = Net()
optimizer = optim.SGD(net.parameters(), lr=0.001, momentum=0.9)
checkpoint = torch.load(PATH)
model.load_state_dict(checkpoint['model_state_dict'])
optimizer.load_state_dict(checkpoint['optimizer_state_dict'])

Now, we have loaded parameters of checkpoint for model, but optimizer loaded parameters of net which is saved into checkpoint.
I think optimizer should be loaded parameters of model rather than net, am i right?

cc @suraj813

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions