Reshape 类keras.layers.Reshape(target_shape, **kwargs)
将输入重塑为指定形状的层。
参数
target_shape 的一个元素可以是 -1,在这种情况下,将根据数组的大小和剩余的维度推断出缺失的值。输入形状
任意,但要求与 target_shape 兼容。
输出形状
(batch_size, *target_shape)
示例
>>> x = keras.Input(shape=(12,))
>>> y = keras.layers.Reshape((3, 4))(x)
>>> y.shape
(None, 3, 4)
>>> # another example with shape inference using `-1` as dimension
>>> y = keras.layers.Reshape((-1, 2, 2))(x)
>>> y.shape
(None, 3, 2, 2)