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数据格式图片.png

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

2 起因剖析
报错信息:“Invalid data”意为有效数据,剖析为“intent_ids”定义的类型与理论应用到的数据类型不统一,导致匹配不到适合的数据。

3 解决办法
将intent_label_ids改为输出数据应用到的类型。
图片.png

此时执行胜利,读取MindSpore Record格式文件,并打印局部数据。
图片.png

输入如下:
图片.png

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教程->数据处理->格局转换
https://mindspore.cn/tutorial...