tensorflow - 对如何处理此维度(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 。
解决方案
推荐阅读
- python - Python 编写 .sh 脚本 - \n 导致脚本无法解析
- excel - 累积所有前几年但同月的值。(动力枢轴)
- java - 如何在 Jersey 中使用 @BackgroundScheduler 注册后台任务
- linux - 我无法更改我的 linux 权限。我想创建一个 .env 文件
- linq - 用于在另一个集合中填充集合的 LINQ 查询
- vaadin - 今天突然:Java live reload 不可用
- python - Python 对象列表更新
- javascript - 我正在尝试使用 npm parcel -g 命令全局安装 Parcel
- javascript - 如何在 Python 中将请求的 JSON 数组写入 CSV 文件?
- postgresql - 如何将 PostgreSQL 12 生成的列转换为普通列?