ONNX简化器
ONNX很棒,但有时太复杂了。
背景
有一天,我想将以下简单的重塑操作导出到ONNX:
import torch
class JustReshape ( torch . nn . Module ):
def __init__ ( self ):
super ( JustReshape , self ). __init__ ()
def forward ( self , x ):
return x . view (( x . shape [ 0 ], x . shape [ 1 ], x . shape [ 3 ], x . shape [ 2 ]))
net = JustReshape ()
model_name = 'just_reshape.onnx'
dummy_input = torch . randn ( 2 ,
2022-05-05 18:00:11
151KB
Python
1