我正在尝试训练一个自动编码器,其输入是与嵌入层的输出连接的一些密集特征。因此,我想使用连接层的输出来输入和标签来训练自动编码器:
<form action="my-account.php" method="post" enctype="multipart/form-data">
Upload a profile image:
<input type="file" name="profileImage"><br>
<input type="submit" name="uploadImage" value="Upload">
我收到以下错误
# Inputs
dense = Input(shape=(train_dense_scaled.shape[1],))
sequences = Input(shape=(train_embed.shape[1],))
# Embedding layer
embed = Embedding(vocab_size, 20, input_length=num_embed_cols)(sequences)
flatten = Flatten()(embed)
ae_input = concatenate([dense, flatten])
# Autoencoder
e_128 = Dense(units=128, activation='relu', kernel_initializer=initializer)(ae_input)
e_64 = Dense(units=64, activation='relu', kernel_initializer=initializer)(e_128)
decoded = Dense(units=128, activation='relu', kernel_initializer=initializer)(e_64)
model = Model(inputs=[sequences,dense], outputs=decoded)
model.compile(loss='mse', optimizer='adam')
model.fit(x=[train_dense_scaled,train_embed], y=ae_input, epochs=200, batch_size=128)
连接层AttributeError Traceback (most recent call last)
<ipython-input-25-f29037b9f7ab> in <module>()
---> 50 model.fit(x=[train_dense_scaled,train_embed], y=ae_inputs, epochs=200, batch_size=128)
...
AttributeError: 'Tensor' object has no attribute 'ndim'
的输出是自动编码器的输入,因此我想用作标签来训练模型。我假设这是我出错的地方,并没有正确地将这个中间层的输出提供给ae_input
方法。