【问题标题】:How to pass latent vector to decoder in LSTM Variational Autoencoder如何在 LSTM 变分自动编码器中将潜在向量传递给解码器
【发布时间】:2019-01-22 13:17:09
【问题描述】:

我正在尝试为文本编写自己的 LSTM 变分自动编码器,并且对编码步骤的工作原理以及我如何对潜在向量 Z 执行采样有了很好的理解。现在的问题是我应该如何将Z 传递给解码器。对于解码器的输入,我有一个起始标记 <s>,它为解码器中的 LSTM 单元留下隐藏状态 h 和单元状态 c

我应该让初始状态hc 都等于Z,只是其中一个,还是其他?

【问题讨论】:

    标签: tensorflow machine-learning deep-learning lstm autoencoder


    【解决方案1】:

    使用RepeatVector,您可以重复潜在输出n 次。然后,将其输入 LSTM。这是一个最小的例子:

     # latent_dim: int, latent z-layer shape. 
     decoder_input = Input(shape=(latent_dim,)) 
    
     _h_decoded = RepeatVector(timesteps)(decoder_input)
     decoder_h = LSTM(intermediate_dim, return_sequences=True)
     _h_decoded = decoder_h(_h_decoded)
    
     decoder_mean = LSTM(input_dim, return_sequences=True)
     _x_decoded_mean = decoder_mean(_h_decoded)
    
     decoder = Model(decoder_input, _x_decoded_mean)
    

    Keras documentation中解释的很清楚。

    【讨论】:

    • 感谢您的回答。据我了解,当使用 VAE 生成文本时,您希望 LSTM 的输出作为输入反馈,基本上消除了 Z 用作输入的可能性,这就是您的示例所示?
    • @Covey LSTM 的输出与输入进行比较,误差通过网络反向传播。
    猜你喜欢
    • 1970-01-01
    • 2017-11-22
    • 2019-09-13
    • 1970-01-01
    • 2023-01-31
    • 2019-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多