non-image/text 数据的 Keras VAE 示例
Keras VAE example on non-image/text data
我正在尝试将此处给出的 VAE 示例 https://blog.keras.io/building-autoencoders-in-keras.html 改编为 non-image/text 数据。
首先,我不明白的是下面函数中的 'args' :
def sampling(args):
z_mean, z_log_sigma = args
epsilon = K.random_normal(shape=(batch_size, latent_dim),
mean=0., std=epsilon_std)
return z_mean + K.exp(z_log_sigma) * epsilon
另外,如何从中随机抽取一些点
z = Lambda(采样, output_shape=(latent_dim,))([z_mean,z_log_sigma])
输入解码器网络生成新数据??
What i don't understand, first off, is the 'args' in below function :
args 是一个包含两个张量(z_mean、z_log_sigma)的元组。这些张量是编码器分成两半的输出。即解码器的输出被解释为正态分布的均值和对数方差。
how to randomly sample some points from z = Lambda(sampling, output_shape=(latent_dim,))([z_mean,z_log_sigma])
这就是 sampling
所做的。它从正态分布中采样形状为 (batch_size, latent_dim)
的张量,然后通过对每个 latent_dim 添加均值并乘以 exp(log_sigma)
来对其进行缩放。
即例如,假设 latent_dim 为 2,则处理从正态分布中采样的随机值 epsilon,使得 sampled[0] = (random_values[:, 0] + z_mean[0]) * exp(z_log_sigmal[0])
和第 1 列相同。
使用 VAE,编码器的输出被解释为高斯分布的参数。然后,采样函数使用这些参数通过转换正态分布采样过程的输出来为这些分布生成随机值。
我正在尝试将此处给出的 VAE 示例 https://blog.keras.io/building-autoencoders-in-keras.html 改编为 non-image/text 数据。
首先,我不明白的是下面函数中的 'args' :
def sampling(args):
z_mean, z_log_sigma = args
epsilon = K.random_normal(shape=(batch_size, latent_dim),
mean=0., std=epsilon_std)
return z_mean + K.exp(z_log_sigma) * epsilon
另外,如何从中随机抽取一些点 z = Lambda(采样, output_shape=(latent_dim,))([z_mean,z_log_sigma])
输入解码器网络生成新数据??
What i don't understand, first off, is the 'args' in below function :
args 是一个包含两个张量(z_mean、z_log_sigma)的元组。这些张量是编码器分成两半的输出。即解码器的输出被解释为正态分布的均值和对数方差。
how to randomly sample some points from z = Lambda(sampling, output_shape=(latent_dim,))([z_mean,z_log_sigma])
这就是 sampling
所做的。它从正态分布中采样形状为 (batch_size, latent_dim)
的张量,然后通过对每个 latent_dim 添加均值并乘以 exp(log_sigma)
来对其进行缩放。
即例如,假设 latent_dim 为 2,则处理从正态分布中采样的随机值 epsilon,使得 sampled[0] = (random_values[:, 0] + z_mean[0]) * exp(z_log_sigmal[0])
和第 1 列相同。
使用 VAE,编码器的输出被解释为高斯分布的参数。然后,采样函数使用这些参数通过转换正态分布采样过程的输出来为这些分布生成随机值。