Machine learning keras中的函数模型:参数无效:必须为占位符张量';编码器输入';使用数据类型float和shape[8,64,10]

Machine learning keras中的函数模型:参数无效:必须为占位符张量';编码器输入';使用数据类型float和shape[8,64,10],machine-learning,tensorflow,keras,Machine Learning,Tensorflow,Keras,这就是我定义的模型 encoder_input = Input(batch_shape=(BATCH_SIZE, MAX_SENTENCE_SIZE, VOCAB_SIZE), name='encoder_input') mask = Masking(mask_value=0.0)(encoder_input) encoded = LSTM(ENCODING_SIZE, return_sequences=False, name='encoded')(

这就是我定义的模型

encoder_input = Input(batch_shape=(BATCH_SIZE, MAX_SENTENCE_SIZE, VOCAB_SIZE), 
                      name='encoder_input')
mask = Masking(mask_value=0.0)(encoder_input)
encoded = LSTM(ENCODING_SIZE, return_sequences=False, name='encoded')(mask)

encoder = Model(encoder_input, encoded) 

# make decoder model
decoder_input = Input(shape=(BATCH_SIZE, ))
decoded = RepeatVector(MAX_SENTENCE_SIZE)(decoder_input)
decoded = LSTM(VOCAB_SIZE, return_sequences=True)(decoded)
decoded = TimeDistributed(Dense(VOCAB_SIZE, activation='softmax', 
                                name='decoded'))(decoded)


decoder = Model(decoder_input, decoded)

# make sequence autoencoder
encoder_decoder_input = Input(batch_shape=(BATCH_SIZE, MAX_SENTENCE_SIZE, VOCAB_SIZE), 
                              name='encoder_decoder_input')
encoder_output = encoder(encoder_decoder_input)
decoder_output = decoder(encoder_output)

sequence_autoencoder = Model(encoder_decoder_input, decoder_output)
sequence_autoencoder.compile(loss='categorical_crossentropy', optimizer='adam')
当我尝试对其进行训练时,使用批次上的训练,并输入正确尺寸的输入和目标,它会给我以下错误:

Invalid argument: You must feed a value for placeholder tensor 'encoder_input' with dtype float and shape [8,64,10]
     [[Node: encoder_input = Placeholder[dtype=DT_FLOAT, shape=[8,64,10], _device="/job:localhost/replica:0/task:0/gpu:0"]()]]

这没有道理。你知道为什么会这样吗

不要在输入形状中使用“批大小”。只使用单个数据样本的形状。(除非该批大小是LSTM层特别需要的,我对此不太了解)。例如:如果您正在使用一批10000张28x28像素的图像进行训练,则您的输入形状仅为(28,28)按照您的建议删除批处理形状并不能解决问题。我必须在编码器输入后立即删除
掩蔽层才能使其工作。但是,我不确定它为什么能解决问题。如果没有一段最小的、自包含的、可复制的代码,我们很难再向您提供建议,因为我们可以运行这段代码来显示问题。这里您似乎没有包含运行模型的代码,这是非常相关的。