flâneur — a map of the web's best reading

torch.triu — PyTorch 2.12 documentation

docs.pytorch.org · 442 words · saved by 1 readers

Returns the upper triangular part of a matrix (2-D tensor) or batch of matrices input, the other elements of the result tensor out are set to 0. The upper triangular part of the matrix is defined as the elements on and above the diagonal. The argument diagonal controls which diagonal to consider. If diagonal = 0, all elements on and above the main diagonal are retained. A positive value excludes just as many diagonals above the main diagonal, and similarly a negative value includes just as many diagonals below the main diagonal. The main diagonal are the set of indices { ( 𝑖 , 𝑖 ) } {(i,i)} for 𝑖 ∈ [ 0 , min ⁡ { 𝑑 1 , 𝑑 2 } − 1 ] i∈[0,min{d 1 ​ ,d 2 ​ }−1] where 𝑑 1 , 𝑑 2 d 1 ​ ,d 2 ​ are the dimensions of the matrix. input (Tensor) – the input tensor. diagonal (int, optional) – the diagonal to consider out (Tensor, optional) – the output tensor. Example: Previous torch.tril_indices Next torch.triu_indices Built with the PyData Sphinx Theme 0.15.4. previous torch.t

torch.triu # torch. triu ( input , diagonal = 0 , * , out = None ) → Tensor # Returns the upper triangular part of a matrix (2-D tensor) or batch of matrices input , the other elements of the result tensor out are set to 0. The upper triangular part of the matrix is defined as the elements on and above the diagonal. The argument diagonal controls which diagonal to consider. If diagonal = 0, all elements on and above the main diagonal are retained. A positive value excludes just as many diagonals above the main diagonal, and similarly a negative value includes just as many diagonals belo

Explore this link on the map →

related reading