【问题标题】:Gumbel-Softmax Activation in a generative adversarial network in Tensorflow 2.1Tensorflow 2.1 中生成对抗网络中的 Gumbel-Softmax 激活
【发布时间】:2020-03-05 10:58:58
【问题描述】:

我的目标是构建一个生成对抗网络,该网络生成一个类别变量的真实外观序列,类似于 [1]。为了使用生成器生成分类序列,我需要使用 Gumbel_Softmax 激活来确保反向传播仍然有效。我在 Tensorflow 2.1 中找不到预先制定的 Gumbel_softmax 激活函数,只有 tfp.distributions.RelaxedOneHotCategorical 应该可以解决我的问题。

在我的示例中,我想生成一个二进制变量序列。 你能给我一个代码示例,说明如何在 tensorflow 函数式 API 中实现这一点。

也许您可以从我当前的代码中了解我的目标:

generator():

    inputs = Input(latent_dim,)

    x = Dense(t_steps* no_states, activation='relu')(inputs)
    x = Reshape((t_steps, no_states))(x)

    x = tfpl.RelaxedOneHotCategorical(temperature=t, logits=no_states, Batch_shape=t_steps)

    outputs=x

    noise = Input(shape=(latent_dim,))
    inp = model(noise)

    return Model(noise, inp)

[1] Kusner 等人的具有 Gumbel-softmax 分布的离散元素序列的 GANS。 2016

【问题讨论】:

    标签: python tensorflow binary sequence softmax


    【解决方案1】:

    我已经为 Tensorflow 2+ 构建了一个自定义 GumbelSoftmax 层。

    与 GAN 一起使用时,据说最好使用逆温度参数,即乘以 y * tau 而不是 y / tau

    https://github.com/gugarosa/nalp/blob/master/nalp/models/layers/gumbel_softmax.py

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-19
      • 1970-01-01
      • 2020-09-25
      • 1970-01-01
      • 2012-04-11
      • 1970-01-01
      • 2018-03-24
      • 1970-01-01
      相关资源
      最近更新 更多