首页 > 解决方案 > 重塑层的输出维度

问题描述

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 尺寸的图像吗?它是什么 ?

对不起,我知道我的理解完全错误。所以我想了解它。

标签: tensorflowmachine-learningkerasdeep-learning

解决方案


在这里,您的模型将采用 (*, 100) 的 input_shape,第一个密集层将输出 (*, 7*7*256) 的形状,最后一个 Reshape 层将将该输出重塑为形状 (*, 7, 7, 256)。

* 是你的 batch_size。

所以是的,基本上,您的形状 (,100) 的“图像”将被重新调整为形状数组 (, 7, 7, 256)。

希望对你有帮助


推荐阅读