Closed lvyufeng closed 4 years ago
the missing scope name use workaround to fix, and the torch.onnx.utils._trace
seems more suitable for conversion.
@lvyufeng, useful code! Thank you for your contribution. It will work with some addtional code on extracting state_dict keys from the scope.
@lvyufeng, we tested your code on several models but it caused some accurancy losses when converting resnet152 and vgg19_bn. Thanks for your contribution and any idea about extracting graph and scope is welcomed.
@lvyufeng, we tested your code on several models but it caused some accurancy losses when converting resnet152 and vgg19_bn. Thanks for your contribution and any idea about extracting graph and scope is welcomed.
is that _optimize_graph
function in torch.onnx.utils
automaticly remove some useful nodes from origin graph?
@lvyufeng , According to Pytorch Tutorial
It is important to call torch_model.eval() or torch_model.train(False) before exporting the model, to turn the model to inference mode. This is required since operators like dropout or batchnorm behave differently in inference and training mode.
when using model.eval()
before _trace()
, we got the correct result.
Thanks for your contribution.
merge in #876
use torch.onnx provided
_trace
function(include optimization)