reshape¶
dragon.
reshape
(
inputs,
shape,
copy=True,
**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:
- inputs (dragon.Tensor) – The input tensor.
- shape (Union[Sequence[int], dragon.Tensor]) – The output shape.
- copy (bool, optional, default=True) – Return a new tensor or call in-place.
- Returns:
dragon.Tensor – The output tensor.