The order of and load_state_dict

This is more a pytorch question. The official torch doc shows that is called after model.load_state_dict as follows:

device = torch.device("cuda")
model = TheModelClass(*args, **kwargs)

However, the fastai learner
first calls in def __post_init__() and then calls load_state_dict in def load().

So is it correct understanding that the order of calling and load_state_dict doesn’t matter? Thank you.

It doesn’t matter in this case because the model was on the same device during the save (since it went through the to function).

1 Like