带有分离解码器和编码器的 Keras AE - 但具有多个输入



>我正在尝试在keras中训练自动编码器。最后,我想有一个单独的编码器和解码器模型。我可以为普通的AE执行此操作,例如:https://blog.keras.io/building-autoencoders-in-keras.html

但是,我想训练模型的条件变体,其中我将条件信息传递给编码器和解码器。(https://www.vadimborisov.com/conditional-variational-autoencoder-cvae.html(

我可以很好地创建编码器和解码器:

# create the encoder
xIn = Input(shape=(100,), name="data_in")
conditional = Input(shape=(10, ), name='conditional')
modelInput = concatenate([xIn,conditional])
x = Dense(25,activation=activation)(modelInput)
xlatent = Dense(5,activation=activation)(x)
# create the encoder
cencoder = Model(inputs=[xIn,conditional],outputs=xlatent, name = "Encoder")
cencoder.summary()

latentState = Input(shape=(5,),name="latentInput")
conditional = Input(shape=(10,),name="conditional")
decoderInput = concatenate([conditional,latentState])
x = Dense(25,activation=activation)(decoderInput)
out = Dense(5,activation=activation)(x)
# create a decoder
cdecoder = Model(inputs=[xIn,conditional],outputs=out)
cdecoder.summary()

但是现在要创建自动编码器,我需要执行以下操作:

encoded = encoder(input)
out = decoder(encoded)
AE = Model(encoded,out)

我该怎么做这样的事情:

encoded = encoder([input,conditional])
out = decoder([encoded,conditional])
AE = Model(encoded,out)

无论我尝试哪种方式,它都会给我一个图形断开连接错误。

谢谢

考虑到两个模型的条件相同

这样做:

encoderInput = Input(shape=(100,), name="auto_data_in")
conditionalInput = Input(shape=(10, ), name='auto_conditional')
encoderOut = cencoder([encoderInput, conditionalInput])
decoderOut = cdecoder([encoderOut, conditionalInput])
AE = Model([encoderInput, conditionalInput], decoderOut)

相关内容

  • 没有找到相关文章

最新更新