首页 > 解决方案 > 对如何处理此维度(Tensorflow)以及如何提取均值和标准差的疑问

问题描述

我正在关注 Youtube 上的 MIT 深度学习入门课程,但我一直停留在这段代码上:

self.encoder = make_standard_classifier(num_encoder_dims)
self.decoder = make_face_decoder_network()

def encode(self, x):
# encoder output
encoder_output = self.encoder(x)

# classification prediction
y_logit = tf.expand_dims(encoder_output[:, 0], -1)
# latent variable distribution parameters
z_mean = encoder_output[:, 1:self.latent_dim+1] 
z_logsigma = encoder_output[:, self.latent_dim+1:]

return y_logit, z_mean, z_logsigma

这是 VAE 中的编码器网络。我不明白 tf.expand_dims 是做什么的,它是在为编码器输出添加维度吗?或者它也获取 encoder_output[:,0] 中的值并返回它?

第二个问题是关于 z_mean 和 z_logsigma。为什么他们在输出的那些位置?他们不应该在上面计算吗?编码器是标准的,因此没有特定的输出,它作为最后一层具有 2*latent dim + 1 个输出的 Dense 。

这是代码https://github.com/aamini/introtodeeplearning/blob/master/lab2/solutions/Part2_Debiasing_Solution.ipynb的网址

标签: tensorflowdeep-learningautoencoder

解决方案


推荐阅读