reshape

dragon.vm.torch.reshape(
  input,
  shape,
  out=None
)[source]

Change the shape of input.

Examples:

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

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

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

dragon.vm.torch.Tensor The output tensor.