MindSpore报错“RuntimeError: Unexpected error. Invalid data.“

1 报错描述

1.1 系统环境

ardware Environment(Ascend/GPU/CPU): CPU
Software Environment:
– MindSpore version (source or binary): 1.6.0
– Python version (e.g., Python 3.7.5): 3.7.6
– OS platform and distribution (e.g., Linux Ubuntu 16.04): Ubuntu 4.15.0-74-generic
– GCC/Compiler version (if compiled from source):

1.2 基本信息

1.2.1脚本

此案例将自定义数据集转化成MindSpore Record数据格式

1.2.2报错

报错信息:RuntimeError: Unexpected error. Invalid data, the number of schema should be positive but got: 0. Please check the input schema.

2 原因分析

报错信息:“Invalid data”意为无效数据,分析为“intent_ids”定义的类型与实际使用到的数据类型不一致,导致匹配不到合适的数据。

3 解决方法

将intent_label_ids改为输入数据使用到的类型。

此时执行成功,读取MindSpore Record格式文件,并打印部分数据。

输出如下:

4 总结

定位报错问题的步骤:
1、找到报错的用户代码行:writer.write_raw_data(data);
2、根据日志报错信息中的提示:“Invalid data, the number of schema should be positive but got: 0. Please check the input schema.”定位到数据输入部分可能出现问题。结合前面的warning:“for schema, 0 th data is wrong, data type for ‘intent_ids’ is not matched.”可定位到intent_ids数据写入时出现报错,检查发现intent_ids是一维数组,遍历时输入为单个数据,而在代码中定义为numpy类型,导致数据读取时匹配不到相关类型数据。
3、数据输入与脚本中的类型定义需要保持一致。

5 参考文档

mindspore教程->数据处理->格式转换
格式转换 — MindSpore master documentation

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值