Python => IndexError:数组的索引过多:数组是二维的,但是索引了3个

问题描述

我的代码在这里,IMG_HEIGHT,宽度通道128,128,3。

for n,id_ in tqdm(enumerate(train_ids),total=len(train_ids)):
path = TRAIN_PATH + id_
img = imread(path + '/images/' + id_ + '.jpg')[:,:,:IMG_CHANNELS]
img = resize(img,(IMG_HEIGHT,IMG_WIDTH),mode='constant',preserve_range=True)
X_train[n] = img  # Fill empty X_train with values from img
mask = np.zeros((IMG_HEIGHT,IMG_WIDTH,1),dtype=np.bool)
for mask_file in next(os.walk(path + '/masks/'))[2]:
    mask_ = imread(path + '/masks/' + mask_file)
    mask_ = np.expand_dims(resize(mask_,preserve_range=True),axis=-1)
    mask = np.maximum(mask,mask_)

错误消息是“ IndexError:数组索引过多:数组是二维的,但是索引了3个 “。我该怎么办?我不知道怎么解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)