tutorials
tutorials copied to clipboard
RuntimeError: ONNX export failed: Couldn't export operator aten::avg_pool2d
How to take care of this error?
/anaconda3/lib/python3.6/site-packages/torch/onnx/symbolic.py:69: UserWarning: ONNX export failed on avg_pool2d because ceil_mode not supported
RuntimeError: ONNX export failed: Couldn't export operator aten::avg_pool2d
The problem is on your network declaration. You are trying to export your model but the parameter ceil_mode=True is not supported for the transformation.
Go to the declaration of your network and change it to e.g.:
nn.AvgPool2d(2, stride=2, ceil_mode=False),)
You can find more info in the documentation: https://pytorch.org/docs/master/nn.html#avgpool2d
Because the symbolic (translation) function is missing, try to follow the (almost up to date) tutorial to extend the support here: https://github.com/onnx/tutorials/blob/master/tutorials/PytorchAddExportSupport.md
Hi @fgtoralesch I try to add ceil_mode=False as you say but somehow I still get this error
any recommend? Thanks
try use pytorch==0.4.0 package
it occured error when my pytorch=0.4.1
I had the same issue In my case, the error was when I use:
import torch.nn.functional as F
...
def forward(self, x):
feat = self.base(x)
feat = F.avg_pool2d(feat, feat.size()[2:])
when I define in my network:
class Model(nn.Module):
def __init__():
...
self.avg_pool2d = nn.AvgPool2d(kernel_size=k_s, ceil_mode=False)
...
def forward(self, x):
...
feat = self.avg_pool2d(feat, feat.size()[2:])
...
everything work