torch.where — PyTorch 1.10.1 documentation
pytorch.org › docs › stabletorch.where(condition, x, y) → Tensor Return a tensor of elements selected from either x or y, depending on condition. The operation is defined as: \text {out}_i = \begin {cases} \text {x}_i & \text {if } \text {condition}_i \\ \text {y}_i & \text {otherwise} \\ \end {cases} outi = {xi yi if conditioni otherwise Note
[feature request] add `torch.find` to find the indices of ...
github.com › pytorch › pytorchJul 12, 2018 · result = torch. find ( tensor, from_) This operator outputs a long tensor of the same shape as the argument tensor, where the result [i,j,..] is the first index at vector from_ whose value is the same as tensor [i,j,..]. For example: a = torch. tensor ( [ 0, 10, 20, 30 ]) b = torch. tensor ( [ [ 0, 30, 5 ], [ 20, 1, 0 ]]) torch. find ( b, a)
torch.triu_indices — PyTorch 1.10.1 documentation
pytorch.org › generated › torchReturns the indices of the upper triangular part of a row by col matrix in a 2-by-N Tensor, where the first row contains row coordinates of all indices and the second row contains column coordinates. Indices are ordered based on rows and then columns. The upper triangular part of the matrix is defined as the elements on and above the diagonal.