MindSpore | IndexError: (‘Not supported index data type, got ‘, None, ‘ type is ‘, )

1.系统环境

硬件环境(Ascend/GPU/CPU): Ascend

执行模式:静态图

Python版本:3.7

操作系统平台:Linux

2. 报错信息

2.1 问题描述

TypeError: For 'Tensor', the type of 'input_data' should be one of '['Tensor', 'ndarray', 'str_', 'list', 'tuple', 'float', 'int', 'bool', 'complex']', but got type 'NoneType'.复制

3. 根因分析

根据报错我们可以知道输入的数据类型不对,从本文的标题可以知道我们得到了一个','(逗号),类型是它。这里指明了报错的大概位置是我们可以去输入里面去找问题

以下代码为输入数据:

     xs_pad = Tensor(shape=[batch_size, None, 80], dtype=mindspore.float32)

    ys_pad = Tensor(shape=[batch_size, 50], dtype=mindspore.int32,)
    ys_in_pad = Tensor(shape=[batch_size, 51], dtype=mindspore.int32, init=One())
    ys_out_pad = Tensor(shape=[batch_size, 51], dtype=mindspore.int32, init=One())
    xs_masks = Tensor(shape=[batch_size, 1, None], dtype=mindspore.float32)
    ys_sub_masks = Tensor(shape=[batch_size, 51, 51], dtype=mindspore.float32, init=One())
    ys_masks = Tensor(shape=[batch_size, 1, 51], dtype=mindspore.float32, init=One())
    ys_lengths = Tensor(shape=[batch_size], dtype=mindspore.int32, init=One())
    xs_chunk_masks = Tensor(shape=[batch_size, 1, None], dtype=mindspore.bool_)复制

我们仔细排查以上代码能够发现ys_pad代码的错误,多了一个逗号。

4. 解决方案

修改如下:

ys_pad = Tensor(shape=[batch_size, 50], dtype=mindspore.int32, init=One())
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值