Returns a new tensor which reference the same Storage
than the given tensor
. The size,
stride, and storage offset are
the same than the given tensor.
The new Tensor
is now going to "view" the same
storage
than the given tensor
. As the result, any
modification in the elements of the Tensor
will have a impact on the
elements of the given tensor
, and vice-versa. No memory copy!
> x = torch.Tensor(2,5):fill(3.14) > print(x) 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 [torch.Tensor of dimension 2x5] > y = torch.Tensor(x) > print(y) 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 [torch.Tensor of dimension 2x5] > y:zero() > print(x) -- elements of x are the same than y! 0 0 0 0 0 0 0 0 0 0 [torch.Tensor of dimension 2x5]