tf.keras.layers.Reshape
View source on GitHub |
Reshapes an output to a certain shape.
Inherits From: Layer
tf.keras.layers.Reshape( target_shape, **kwargs )
Arguments | |
---|---|
target_shape | Target shape. Tuple of integers, does not include the samples dimension (batch size). |
Input shape:
Arbitrary, although all dimensions in the input shaped must be fixed. Use the keyword argument input_shape
(tuple of integers, does not include the samples axis) when using this layer as the first layer in a model.
Output shape:
(batch_size,) + target_shape
Example:
# 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)
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/layers/Reshape