为了账号安全,请及时绑定邮箱和手机立即绑定

ValueError:检查输入时出错:预期 input_1 具有形状 (None, 65563)

ValueError:检查输入时出错:预期 input_1 具有形状 (None, 65563)

一只名叫tom的猫 2021-10-19 16:31:26
我有一个用 Keras 编写的自动编码器,如下所示。我收到以下错误,不知道如何解决,有什么想法吗?ValueError:检查输入时出错:预期 input_1 具有形状 (None, 65563) 但得到的数组具有形状 (374, 65536)from keras.layers import Input, Dense, Flattenfrom keras.models import Modelfrom keras.preprocessing.image import img_to_arrayimport cv2import numpyimport ostraining_directory = '/training'validation_directory ='/validation'results_directory = '/results'training_images = []validation_images = []# the size of the encoded represenatationencoding_dimension = 784# input placeholderinput_image = Input(shape=(65563,))# the encoded representation of the inputencoded = Dense(encoding_dimension,activation='relu')(input_image)# reconstruction of the input (lossy)decoded = Dense(65563,activation='sigmoid')(encoded)# map the input image to its reconstructionautoencoder = Model(input_image,decoded)# encoder model# map an input image to its encoded representationencoder = Model(input_image,encoded)# decoder model# place holder fpr an encoded inputencoded_input = Input(shape=(encoding_dimension,))# retrieve the last layer of the autoencoder modeldecoder_layer = autoencoder.layers[-1]# create the decoder modeldecoder = Model(encoded_input,decoder_layer(encoded_input))for root, dirs, files in os.walk(training_directory):    for file in files:        image = cv2.imread(root + '/' + file)        image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)        image = img_to_array(image)        training_images.append(image)training_images = numpy.array(training_images)for root, dirs, files in os.walk(validation_directory):    for file in files:        image = cv2.imread(root + '/' + file)        image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)        image = img_to_array(image)        validation_images.append(image)validation_images = numpy.array(validation_images)谢谢。
查看完整描述

1 回答

?
拉丁的传说

TA贡献1789条经验 获得超8个赞

写作65563而不是65536可能是导致问题的错字。


查看完整回答
反对 回复 2021-10-19
  • 1 回答
  • 0 关注
  • 238 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信