Closed dlml closed 5 years ago
import torch import torchvision from crnn import cnn
model = cnn.CRNN(32, 1, 3343, 256) model.load_state_dict(torch.load('pytorch-crnn.pth')) model.eval()
example = torch.rand(1, 1, 32, 280)
traced_script_module = torch.jit.trace(model, example) traced_script_module.save("model.pt")
Traceback (most recent call last): File "E:/train_pytorch/test.py", line 16, in traced_script_module.save("model.pt") AttributeError: 'function' object has no attribute 'save'
Version?
you have a version that's not our "Preview" build. It's probably version 0.4.1 or earlier.
Use our 1.0 Preview build (see pytorch.org ) for jit functionality
import torch import torchvision from crnn import cnn
An instance of your model.
model = cnn.CRNN(32, 1, 3343, 256) model.load_state_dict(torch.load('pytorch-crnn.pth')) model.eval()
An example input you would normally provide to your model's forward() method.
example = torch.rand(1, 1, 32, 280)
Use torch.jit.trace to generate a torch.jit.ScriptModule via tracing.
traced_script_module = torch.jit.trace(model, example) traced_script_module.save("model.pt")
Traceback (most recent call last): File "E:/train_pytorch/test.py", line 16, in
traced_script_module.save("model.pt")
AttributeError: 'function' object has no attribute 'save'