A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.pytorch.org/docs/stable/generated/torch.narrow_copy.html below:

torch.narrow_copy — PyTorch 2.8 documentation

Same as Tensor.narrow() except this returns a copy rather than shared storage. This is primarily for sparse tensors, which do not have a shared-storage narrow method.

>>> x = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> torch.narrow_copy(x, 0, 0, 2)
tensor([[ 1,  2,  3],
        [ 4,  5,  6]])
>>> torch.narrow_copy(x, 1, 1, 2)
tensor([[ 2,  3],
        [ 5,  6],
        [ 8,  9]])
>>> s = torch.arange(16).reshape(2, 2, 2, 2).to_sparse(2)
>>> torch.narrow_copy(s, 0, 0, 1)
tensor(indices=tensor([[0, 0],
                       [0, 1]]),
       values=tensor([[[0, 1],
                       [2, 3]],

                      [[4, 5],
                       [6, 7]]]),
       size=(1, 2, 2, 2), nnz=2, layout=torch.sparse_coo)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4