我是z Keras 的新手,并且一直在努力理解他们官方github 中变分自动编码器示例中变量的用法。我不明白为什么z没有被使用而不是变量latent_inputs。我运行了代码,它似乎有效,但我不明白是否z在幕后使用,以及 Keras 中负责它的机制是什么。这是相关的代码片段:
# VAE model = encoder + decoder
# build encoder model
inputs = Input(shape=input_shape, name='encoder_input')
x = Dense(intermediate_dim, activation='relu')(inputs)
z_mean = Dense(latent_dim, name='z_mean')(x)
z_log_var = Dense(latent_dim, name='z_log_var')(x)
# use reparameterization trick to push the sampling out as input
# note that "output_shape" isn't necessary with the TensorFlow backend
z = Lambda(sampling, output_shape=(latent_dim,), name='z')([z_mean, z_log_var])
# instantiate encoder model
encoder = Model(inputs, [z_mean, z_log_var, z], name='encoder') …Run Code Online (Sandbox Code Playgroud)