A RetroSearch Logo

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

Search Query:

Showing content from https://docs.pytorch.org/docs/main/generated/torch.diagonal_scatter.html below:

torch.diagonal_scatter — PyTorch main documentation

Embeds the values of the src tensor into input along the diagonal elements of input, with respect to dim1 and dim2.

This function returns a tensor with fresh storage; it does not return a view.

Note

src must be of the proper size in order to be embedded into input. Specifically, it should have the same shape as torch.diagonal(input, offset, dim1, dim2)

>>> a = torch.zeros(3, 3)
>>> a
tensor([[0., 0., 0.],
        [0., 0., 0.],
        [0., 0., 0.]])

>>> torch.diagonal_scatter(a, torch.ones(3), 0)
tensor([[1., 0., 0.],
        [0., 1., 0.],
        [0., 0., 1.]])

>>> torch.diagonal_scatter(a, torch.ones(2), 1)
tensor([[0., 1., 0.],
        [0., 0., 1.],
        [0., 0., 0.]])

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