我有一个已展平的图像列表(50*45->2250(。我想把它用作自动编码器的输入。当我"安装"自动编码器时,我会得到以下错误:
"检查输入时出错:预期input_4具有形状(2250,(,但得到的数组具有形状(1,(";
为什么输入形状(1,(?
train_images2 =[]
for im in train_images:
im = transform.resize(im,(50,45),mode='constant',anti_aliasing=True)
im = im[:,:,0]
im = im/255.0
im = im.flatten()
train_images2.append(im)
train_images = train_images2.copy()
print(np.asarray(train_images).shape) #(792, 2250)
print(train_images[0].shape) #(2250,)
# Dimensie van de hidden encoding layer
encoding_dim = 64
# Placeholder voor input
input_img = Input(shape=(2250))
# "encoded" representation
encoded = Dense(encoding_dim, activation='relu')(input_img)
# "decoded" representation
decoded = Dense(2250, activation='sigmoid')(encoded)
# Creëer de autoencoder
autoencoder = Model(input_img, decoded)
autoencoder.summary()
解决方案:"train_images"是一个列表。我不得不把它改成数组。
train_images=np.array(train_images(