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

Logo

鲲鹏昇腾开发者社区是面向全社会开放的“联接全球计算开发者,聚合华为+生态”的社区,内容涵盖鲲鹏、昇腾资源,帮助开发者快速获取所需的知识、经验、软件、工具、算力,支撑开发者易学、好用、成功,成为核心开发者。

更多推荐