huawei-noah / Efficient-AI-Backbones

Efficient AI Backbones including GhostNet, TNT and MLP, developed by Huawei Noah's Ark Lab.
4.07k stars 708 forks source link

ghostnet_pytorch中的hardsigmoid无法转成onnx的hardsigmoid #190

Open DamonsJ opened 1 year ago

DamonsJ commented 1 year ago

测试了ghostnet_pytorch中的模型,用的预训练的pth,转成onnx 结果hardsigmoid拆成了3个,不是单独的hardsigmoid是为什么呢? 这么转的onnx: def main(): args = parser.parse_args()

model = ghostnet(num_classes=args.num_classes, width=args.width, dropout=args.dropout)
model.load_state_dict(torch.load('./models/state_dict_73.98.pth'))
args.num_gpu = 0
if args.num_gpu > 1:
    model = torch.nn.DataParallel(model, device_ids=list(range(args.num_gpu))).cuda()
elif args.num_gpu < 1:
    model = model
else:
    model = model.cuda()
print('GhostNet created.')

model.eval()
x=torch.randn((1,3,224,224))
torch.onnx.export(model, x, 'ghostnet.onnx', opset_version=11)
iamhankai commented 1 year ago

It's normal.