When using torch.onnx.export(), errors occurs: AssertionError: Only output_size=[1, 1] is supported

The original AlexNet definition in v0.2.1 does not have AdaptiveAvgPool2d, but v0.2.2 does. As stated in the error log, the error is mainly caused by AdaptiveAvgPool2d having output size other than [1,1].

I had the same error as you, solved by changing it to fixed size pooling (nn.AvgPool2d).

2 Likes