【发布时间】: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