Nyedago 2024-05-13 20:46 采纳率: 100%
浏览 9
已结题

informer如何转onnx

informer有四个输入

batch_x = batch_x.float().to(self.device)
batch_y = batch_y.float().to(self.device)
batch_x_mark = batch_x_mark.float().to(self.device)
batch_y_mark = batch_y_mark.float().to(self.device)

dec_inp = torch.zeros_like(batch_y[:, -self.args.pred_len:, :]).float()
dec_inp = torch.cat([batch_y[:, :self.args.label_len, :], dec_inp], dim=1).float().to(self.device)

input_names = ('x_enc', 'x_mark_enc', 'x_dec', 'x_mark_dec')
model_input = (batch_x, batch_x_mark, dec_inp, batch_y_mark)
torch.onnx.export(self.model, model_input, f='model.onnx', input_names=input_names)

感谢大家,astype报错解决了,现在报错看不懂了:
torch.onnx.errors.SymbolicValueError: ONNX symbolic expected a constant value of the 'high' argument, got '209 defined in (%209 : int[] = prim::ListConstruct(%182, %208), scope: models.Informer.Model::/layers.Transformer_EncDec.Encoder::encoder/layers.Transformer_EncDec.EncoderLayer::attn_layers.0/layers.SelfAttention_Family.AttentionLayer::attention/layers.SelfAttention_Family.ProbAttention::inner_attention
)' [Caused by the value '209 defined in (%209 : int[] = prim::ListConstruct(%182, %208), scope: models.Informer.Model::/layers.Transformer_EncDec.Encoder::encoder/layers.Transformer_EncDec.EncoderLayer::attn_layers.0/layers.SelfAttention_Family.AttentionLayer::attention/layers.SelfAttention_Family.ProbAttention::inner_attention
)' (type 'List[int]') in the TorchScript graph. The containing node has kind 'prim::ListConstruct'.]

Inputs:
    #0: 182 defined in (%182 : Long(requires_grad=0, device=cpu) = onnx::Constant[value={36}](), scope: models.Informer.Model::/layers.Transformer_EncDec.Encoder::encoder/layers.Transformer_EncDec.EncoderLayer::attn_layers.0/layers.SelfAttention_Family.AttentionLayer::attention/layers.SelfAttention_Family.ProbAttention::inner_attention # /home/ljh/test/FEDformer-master/layers/SelfAttention_Family.py:56:0
)  (type 'Tensor')
    #1: 208 defined in (%208 : Long(device=cpu) = onnx::Constant[value={12}](), scope: models.Informer.Model::/layers.Transformer_EncDec.Encoder::encoder/layers.Transformer_EncDec.EncoderLayer::attn_layers.0/layers.SelfAttention_Family.AttentionLayer::attention/layers.SelfAttention_Family.ProbAttention::inner_attention
)  (type 'Tensor')
Outputs:
    #0: 209 defined in (%209 : int[] = prim::ListConstruct(%182, %208), scope: models.Informer.Model::/layers.Transformer_EncDec.Encoder::encoder/layers.Transformer_EncDec.EncoderLayer::attn_layers.0/layers.SelfAttention_Family.AttentionLayer::attention/layers.SelfAttention_Family.ProbAttention::inner_attention
)  (type 'List[int]')
  • 写回答

3条回答 默认 最新

  • 专家-皆知 2024-05-13 20:46
    关注

    使用ONNX转换工具,传入模型和输入名称列表。

    以上回复有部分引自免费微信小程序:皆我百晓生。 如问题尚未解决,还请稍待,如有疑问请回复进一步沟通。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 5月23日
  • 已采纳回答 5月15日
  • 修改了问题 5月13日
  • 创建了问题 5月13日

悬赏问题

  • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
  • ¥15 安装quartus II18.1时弹出此error,怎么解决?
  • ¥15 keil官网下载psn序列号在哪
  • ¥15 想用adb命令做一个通话软件,播放录音
  • ¥30 Pytorch深度学习服务器跑不通问题解决?
  • ¥15 部分客户订单定位有误的问题
  • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
  • ¥15 Bug traq 数据包 大概什么价
  • ¥15 在anaconda上pytorch和paddle paddle下载报错
  • ¥25 自动填写QQ腾讯文档收集表