AttributeError Pytorch in torch.load appears () in: Can not get attribute

Reason: preserved model parameters and can not without a class definition used when directly.

Pickle Pytorch use to process the save / load model, the problem is actually a problem Pickle, not Pytorch.

Solution is very simple, just to explicitly import the class definition. File contains the class definition is about to copy and paste the file you want to run the same folder, and then import Class!

However, in the actual process, we adopt the method of import Class did not play a role, and the class definition is a feasible method to copy directly on the file to run.

Guess you like

Origin www.cnblogs.com/lucifer1997/p/11412407.html