我在将图像转换为数组时遇到了一个问题,在重塑数组时,这显示给我
ValueError: cannot reshape array of size 43200 into shape (3,120,160)
这是我的代码:
img_size = 224
i = 0
for _file in train_files:
img = load_img(data_dir + "/" + _file , target_size=(224,224)) # this is a PIL imageflowers[0], target_size=(224,224))
img.thumbnail((image_width, image_height))
# Convert to Numpy Array
x = img_to_array(img)
x = x.reshape((3, 120, 160))
# Normalize
x = (x - 255.0) / 255.0
dataset[i] = x
i += 1
if i % 250 == 0:
print("%d images to array" % i)
print("All images to array!")
我该如何解决这个问题?