|TensorFlow 1 version||View source on GitHub|
Reshapes an output to a certain shape.
Compat aliases for migration
See Migration guide for more details.
tf.keras.layers.Reshape( target_shape, **kwargs )
||Target shape. Tuple of integers, does not include the samples dimension (batch size).|
Arbitrary, although all dimensions in the input shaped must be fixed.
Use the keyword argument
(tuple of integers, does not include the samples axis)
when using this layer as the first layer in a model.
(batch_size,) + target_shape
# as first layer in a Sequential model model = Sequential() model.add(Reshape((3, 4), input_shape=(12,))) # now: model.output_shape == (None, 3, 4) # note: `None` is the batch dimension # as intermediate layer in a Sequential model model.add(Reshape((6, 2))) # now: model.output_shape == (None, 6, 2) # also supports shape inference using `-1` as dimension model.add(Reshape((-1, 2, 2))) # now: model.output_shape == (None, None, 2, 2)