adaber:

A model instance/object has to be initialized before we can load the model weight values to the object from a file if I understand correctly. Let me know if I am mistaken.


That’s the recommended way. You would initialize the same model and just load the state_dict into it.



 adaber:

would there be a way to pull that information from a saved file prior to loading so I could “dynamically” initialize a UNet object that will have a valid structure for storing the data from the saved file ?


The usual approach is to create a dict and store everything inside it.
E.g. you could store the model.state_dict(), optimizer.state_dict() as well as your depth level.
Once you’ve created this dict, you could store and load it directly using torch.save and torch.load, respectively.