【问题标题】:regarding the decoder layer definition in autoencoder model under Keras framework关于 Keras 框架下自编码器模型中的解码器层定义
【发布时间】:2017-04-18 02:11:30
【问题描述】:

this blog中包含的自动编码器示例中,作者构建一个隐藏层如下。

 # this is the size of our encoded representations
 encoding_dim = 32  # 32 floats -> compression of factor 24.5, assuming the input is 784 floats
 input_img = Input(shape=(784,))
 encoded = Dense(encoding_dim, activation='relu')(input_img)
 decoded = Dense(784, activation='sigmoid')(encoded)
 autoencoder = Model(input=input_img, output=decoded)

 # this model maps an input to its encoded representation
 encoder = Model(input=input_img, output=encoded)

我可以理解上面的部分是如何工作的,但是我对下面构建解码器部分的部分感到困惑

 # create a placeholder for an encoded (32-dimensional) input
 encoded_input = Input(shape=(encoding_dim,))
 # retrieve the last layer of the autoencoder model
 decoder_layer = autoencoder.layers[-1]
 # create the decoder model
 decoder = Model(input=encoded_input, output=decoder_layer(encoded_input))

具体来说,我认为decoder 应该定义为decoder = Model(input=encoded, output=decoded)。我不明白为什么我们必须引入额外的变量encoded_input。根据自动编码器模型,我们只是将编码部分解码为输出,因此解码器层的输入应该是encoded。 而且,如果解码器模型定义如上,为什么编码器没有定义为encoder=Model(input=input_img, output=autoencoder.layers[0](input_img))

【问题讨论】:

    标签: tensorflow deep-learning theano keras keras-layer


    【解决方案1】:

    encoded_input 表示一个占位符,如果您只想对生成的某些数据运行解码器而不是编码器(例如,如果您正在探索编码空间),则可以使用该占位符。

    【讨论】:

      猜你喜欢
      • 2017-04-18
      • 2023-03-09
      • 2019-06-14
      • 2022-07-05
      • 2019-09-13
      • 2019-07-12
      • 2019-05-19
      • 2019-08-22
      • 1970-01-01
      相关资源
      最近更新 更多