[Solved] MindSpore Error: “RuntimeError: Unexpected error. Inconsistent batch..

1 Error description

1.1 System Environment

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

1.2 Basic information

1.2.1 Script

This case customizes the dataset and performs batch operations.
picture.png

1.2.2 Error reporting

RuntimeError: Unexpected error. Inconsistent batch shapes, batch operation expect same shape for each data row, but got inconsistent shape in column 0, expected shape for this column is:, got shape:
picture.png

2 Reason analysis

According to the error message, the batch operation needs to input the same shape of the dataset, but the shape of the custom dataset is not uniform, resulting in an error.

3 Solutions

1. Remove the batch operation.
picture.png

2. If you must perform batch operations on data with inconsistent shapes, you need to organize the data set and unify the shape of the input data through pad completion and other methods.

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *