RuntimeError: Exporting the operator repeat_interleave to ONNX opset version 9 is not supported.

UserWarning: You are trying to export the model with onnx:Upsample for ONNX opset version 9. This operator might cause results to not match the expected results by PyTorch.
ONNX's Upsample/Resize operator did not match Pytorch's Interpolation until opset 11. Attributes to determine how to transform the input were added in onnx:Resize in opset 11 to support Pytorch's behavior (like coordinate_transformation_mode and nearest_mode).
We recommend using opset 11 and above for models using this operator. 

UserWarning: ONNX export failed on ATen operator repeat_interleave because torch.onnx.symbolic_opset9.repeat_interleave does not exist

RuntimeError: Exporting the operator repeat_interleave to ONNX opset version 9 is not supported. Please open a bug to request ONNX export support for the missing operator.

 

pytorch转onnx报的错,原因是pytorch中的repeat_interleave操作在onnx中还不支持,可以把这个操作换成别的,比如coordinate_transformation_mode 和 nearest_mode

repeat_interleave() 可以用 repeat() 和 view() 替换掉

举个例子,随机一个x,x的大小是1*1*2*2,分别对应第0,1,2,3维度

我想将x的第2维度,复制4次,如下所示

x = torch.randn(1, 1, 2, 2)
x = torch.repeat_interleave(x, 4, 2)

然后,这两种方法是等价的

x = torch.randn(1, 1, 2, 2)
x = x.repeat(1, 1, 4, 1)

 

你可能感兴趣的:(pytorch,pytorch,人工智能,深度学习)