>>> a = torch.arange(4.)
>>> torch.reshape(a, (2, 2))
tensor([[ 0., 1.],
[ 2., 3.]])
>>> b = torch.tensor([[0, 1], [2, 3]])
>>> torch.reshape(b, (-1,))
tensor([ 0, 1, 2, 3])
torch.reshape(input, shape) → Tensor
参数 | 描述 |
---|---|
input (Tensor) | |
shape (tuple of python:ints) |
参考:
https://pytorch.org/docs/stable/generated/torch.reshape.html#torch.reshape
https://pytorch.org/docs/stable/tensors.html#torch.Tensor.view