【MindSpore】[CRITICAL] ANALYZER: The ‘getitem’ operation does not support the type [func,int64].

报错:[CRITICAL] ANALYZER: The ‘getitem’ operation does not support the type [func,int64]. The supported types of overload function ‘getitem’ is [Tensor, Tuple], [Tensor, Tensor],[Tensor, Slice],[Tensor, kMetaTypeNone],[Tensor,Number],[Dictionary, string],[Tuple,Tensor],Tensor, kmetatypeElipsis]
在这里插入图片描述
目前遇到这个问题的一种场景是,接口使用错误:
错误场景如下:

线性层定义
"__init__"
self.fc_layers = nn.SequentialCell(lin_layers)
使用调用方式:
"construct"
for idx in range(23):
    o.append(self.fc_layers[idx](x))

错误的使用SequentialCell,SequentialCell中的Cell是以级联方式连接的,不是单纯的存储。
这里for循环其实就是类似于list的方式调用线性Cell,这种方式可以修改为使用CellList修改如下:

self.fc_layers = nn.CellList(lin_layers)

改为CellList之后可以像python的列表一样使用。

具体的使用容器构建网络的方式可以参考MindSpore官网教程

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值