Closed
Description
Hi. thanks for the repository.
I'm failing to visualize a PyTorch model that I save with the following line:
torch.save(model.state_dict(), 'model.pth')
and then I get this Error from Netron :
"Error loading PyTorch model. File does not contain a model graph. Use 'torch.save()' to save both the graph and tensor data."
But when I convert it to ONNX in the following way, I'm able to visualize the ONNX model :
torch.onnx.export(model, img, 'model.onnx')
Also when I tried to save the full model in PyTorch (without the ".state_dict()" part), I don't get the error but it doesn't show the correct Graph and only a single-node graph basically is displayed.
Any clue how to resolve this issue?
Activity
lutzroeder commentedon Mar 11, 2019
.pth
does not save the full graph but only top level nodes as the rest is encoded in Python modules. Using.onnx
will save the full graph.Load PyTorch weights only files (#236)
Load PyTorch weights only files (#236)
Load PyTorch weights only files (#236)
Load PyTorch weights only files (#236)
Load PyTorch weights only files (#236)
Load PyTorch weights only files (#236)
Load PyTorch weights only files (#236)
lutzroeder commentedon Apr 11, 2021
Duplicate of #133.
[-]Not able to visualize PyTorch model[/-][+]PyTorch: File does not contain root module or state dictionary.[/+][-]PyTorch: File does not contain root module or state dictionary.[/-][+]PyTorch: File does not contain root module or state dictionary[/+]2 remaining items