Reshape

class dragon.vm.tensorflow.keras.layers.Reshape(
  target_shape,
  **kwargs
)[source]

The layer to change the dimensions of input.

Examples:

x = tf.random.uniform((2, 1, 3))

# (2, 1, 3) => (2, 3)
# Note that the dimensions should start from axis 1
print(tf.keras.layers.Reshape([3])(x))

# (2, 1, 3) => (2, 3)
# At most one dimension could be set to ``-1``
# to infer the remain elements
print(tf.keras.layers.Reshape([-1])(x))

# (2, 1, 3) => (2, 1, 3)
# Set dimension to ``0`` will keep it unchanged
print(tf.keras.layers.Reshape([0, -1])(x))

__init__

Reshape.__init__(
  target_shape,
  **kwargs
)[source]

Create a Reshape layer.

Parameters:
  • target_shape (Sequence[int]) – The output dimensions.