reshape

dragon.reshape(
  inputs,
  shape,
  **kwargs
)[source]

Change the dimensions of input.

Examples:

# Provide a determined value for each dimension if possible
x = dragon.ones(shape=(1, 2, 3, 4))
print(dragon.reshape(x, shape=[6, 4]).shape)  # [6, 4]

# Set the existing dimensions to ``0`` if it unchanged
print(dragon.reshape(x, shape=[0, 0, 12]).shape)  # [1, 2, 12]
print(dragon.reshape(x, shape=[0, 0, 0, 0]).shape)  # [1, 2, 3, 4]
print(dragon.reshape(x, shape=[0, 0, 0, 0, 0]).shape)  # Wrong

# You can also set ``-1`` once to infer the value
print(dragon.reshape(x, shape=[-1, 4]).shape)  # [6, 4]
print(dragon.reshape(x, shape=[-1, -1]).shape)  # Wrong
Parameters:
Returns:

dragon.Tensor – The output tensor.