问题描述:
报错如下:
[ERROR] MD(108,fffe0bfff160,python):2022-03-04-10:24:16.338.482 [mindspore/ccsrc/minddata/dataset/util/task_manager.cc:217] InterruptMaster] Task is terminated with err msg(more detail in info level log):Unexpected error. Invalid data, batch operation expect same shape for each data row, but got inconsistent shape in column 1 expected shape for this column is:<1,388,388>, got shape:<2,388,388>
【操作步骤&问题现象】
1、我按照gitee上Unet的代码,修改了自己的数据集,数据集的格式都保持和gitee上一致,但是换过以后出现了以上的问题,我的数据集有320张,gitee用的是ISBI果蝇腹部的数据集,然后当我将我自己的数据集变为20张的时候,就没有上面的报错了,请问是什么原因呢?
2、unet · MindSpore/course - 码云 - 开源中国 (gitee.com) 参考的是这个代码,只是换了一下数据集
3、数据预处理中有以下,不是很清楚这步的作用是啥
train_images = np.repeat(train_images, repeat, axis=0)
train_masks = np.repeat(train_masks, repeat, axis=0)
4、经过一些列预处理后,batch的时候mask已经处理为了2*388*388,不知道为什么还会有1*388*388出现哎
解答:
您好,您这个错误是说,mindspore的数据处理阶段batch算子出错,当前batch必须要内存对齐,举个例子,如果说batch_size=2,意思是说我们每次会将两条数据batch到一起,这个就要求这两条数据的shape必须要一致,上面的错误就是因为同一个batch的数据内,有shape不一致的数据存在,这边可以提供以下的自检方案: 您在数据处理的batch算子之前遍历一下数据:
for item in dataset.create_dict_iterator(output_numpy=True):
print(item["mask"].shape)
dataset = dataset.batch(batch_size=xxx, drop_remainder=True)
在batch之前遍历数据,您应该会发现有某一条数据的shape是<2,388,388>,预计应该都是<1,388,388>