According to the tutorials 1
one has to define a model and an optimizer first and then load the states from file. But I am wondering, how I am to initialize for instance the optimizer if I only have access to the parameters later?
model = TheModelClass(*args, **kwargs)
optimizer = TheOptimizerClass(*args, **kwargs)

checkpoint = torch.load(PATH)
model.load_state_dict(checkpoint['model_state_dict'])
optimizer.load_state_dict(checkpoint['optimizer_state_dict'])

thank you