why load_from_checkpoint is not defaultly inplace? #6888
-
Why
instead of
The former one is not friendly to native PyTorch users. And cost me an afternoon to find the bug. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
load_from_checkpoint
is a class function which instantiates the object with thehyper_parameters
in the checkpoint and then loads the state_dict.If done like in your proposal
my_model.load_from_checkpoint(checkpoint_path="example.ckpt")
similar to pytorch'sload_state_dict
you'd have to create themy_model
object first with thehyper_parameters
parsed from the checkpoint and then load the weights.load_from_checkpoint
combines both.Maybe adding a way to load the
state_dict
from a checkpoint into an already instantiated object without using a classmethod would make sense. Something likeload_state_dict_from_checkpoint
.The alternative is to load the checkpoint and then call
model.load_st…