Hi, I wish to extract/modify several module outputs from Resnet50 pre-trained model. I desire to do so before the dequantized layers. I decided to see the model graph with Netron to know which ones I want. Because of that, I transformed the torchvision model to a onnx model with the following code:
weights = models.ResNet50_QuantizedWeights.DEFAULT
model = models.resnet50(weights=weights, quantize=True)
dummy_input = torch.randn(125, 3, 224, 224)
input_names = [ "actual_input" ]
output_names = [ "output" ]
torch.onnx.export(model,
dummy_input,
"resnet50torch2-int8prova.onnx",
input_names=input_names,
output_names=output_names
)
The resulting graph is the following:
The output I want is named “onnx::DequantizeLinear_148”, which is also the input of a dequantize layer. However, my problem is that I don’t know how to identify this output in the pytorch model. When I print the model, there are no names and the model’s graph changes completely:
How can I search the outputs by name and then modify or obtain for example, with some hooks? Any information or background or example code will help.
Thank you.