tensorflow - 重塑层的输出维度
问题描述
model = tf.keras.Sequential()
model.add(layers.Dense(7*7*256, use_bias=False, input_shape=(100,)))
model.add(layers.BatchNormalization())
model.add(layers.LeakyReLU())
model.add(layers.Reshape((7, 7, 256)))
密集层接受 1*100 维度的输入。它在其层中使用 7*7*256 个节点。重塑层以 1*(7*7*256) 作为输入,它的输出是什么。我的意思是 (7, 7, 256) 是什么意思?
如果我们将输入作为 1*100 的图像,它是 7 * 7 尺寸的图像吗?它是什么 ?
对不起,我知道我的理解完全错误。所以我想了解它。
解决方案
在这里,您的模型将采用 (*, 100) 的 input_shape,第一个密集层将输出 (*, 7*7*256) 的形状,最后一个 Reshape 层将将该输出重塑为形状 (*, 7, 7, 256)。
* 是你的 batch_size。
所以是的,基本上,您的形状 (,100) 的“图像”将被重新调整为形状数组 (, 7, 7, 256)。
希望对你有帮助
推荐阅读
- html5-canvas - 在 file:/// 元素上使用 toDataURL 导出 Canvas 会导致污染错误,即使在本地资源上也是如此
- python - 为什么使用 Pillow 在 python 中保存图像时出现错误?
- list - 在列表理解中创建动态键
- r - 来自 Metrics 包的偏差和来自预测包的 ME 在 R 中产生相同的值,为什么?
- python - 没有非线性的 Pytorch RNN
- javascript - 使用Javascript将字符串更改为数字时如何保留前导零?
- python - 从 JSON 文件循环打印
- python - 加入类列表列表
- javascript - 缺少翻译 i18n,只返回密钥
- ssl - Beanstalk 单实例和 NodeJS - https 不起作用