as1d¶
- dnois.torch.as1d(x: Tensor, ndim: int = 1, dim: int = -1) Tensor ¶
Transforms
x
into andim
-D tensor but arranges its all elements into dimensiondim
.>>> x = torch.arange(4) >>> as1d(x) tensor([0, 1, 2, 3])
- Parameters:
x (Tensor) – A tensor with any shape.
ndim (int) – Number of dimensions of resulted tensor.
dim – The dimension to place elements in.
- Returns:
The transformed tensor.
- Return type:
Tensor