Hi,
I would like to export pth file (without network code) to onnx, how to do that?
Hi,
I would like to export pth file (without network code) to onnx, how to do that?
Could you describe that this pth
file would contain? Would it be the state_dict
or the model or any tensors?
@ptrblck ,
Thank you!
There are 2 cases:
how to export those 2 kinds of pth to onnx?
state_dict
contains all parameters and buffers and neither the model definition not any model code, so you can’t directly export it and would need to create a model instance first.@ptrblck ,
Thank you!
if the pth file contains only state_dict, is there a way to export the model to onnx?
If the pth file contains the model, I should export the model to onnx like this:
model = torch.load(PATH)
model.eval()
torch.onnx.export(model, dummy_input, "alexnet.onnx", verbose=True, input_names=input_names, output_names=output_names)
state_dict
only contains parameters and buffers and no model definition.