pytorch / pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration
https://pytorch.org
Other
83.69k stars 22.58k forks source link

AttributeError: 'function' object has no attribute 'save' #14174

Closed dlml closed 5 years ago

dlml commented 5 years ago

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'

ssnl commented 5 years ago

Version?

soumith commented 5 years ago

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