报错:[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官网教程