PyTorch
torch / torch
torch.narrow¶
-
torch.
narrow
(input, dim, start, length) → Tensor¶ Returns a new tensor that is a narrowed version of
input
tensor. The dimensiondim
is input fromstart
tostart + length
. The returned tensor andinput
tensor share the same underlying storage.- Parameters
Example:
>>> x = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> torch.narrow(x, 0, 0, 2) tensor([[ 1, 2, 3], [ 4, 5, 6]]) >>> torch.narrow(x, 1, 1, 2) tensor([[ 2, 3], [ 5, 6], [ 8, 9]])
此页内容是否对您有帮助
感谢反馈!