I have saved the model using the torch.save(_model, PATH1) function and weights in torch.save(‘model_state_dict’: _model.state_dict(), PATH2).
I want to load the model from another system.
When I load the “_model” I get the error saying that the model architecture is not defined (Can’t get attribute ‘Net’) and had to instantiate the class that creates the model and then load the weights from the checkpoint _model.state_dict in path2.
Is there a way to save both the weights and architecture in a file so that I need not depend on the class definition file, to first create the model object and then load the weights from state dict?
I am looking for a solution similar to what Lua+Torch implementation of torch.save(model, path) does.