torch.max — PyTorch 1.10.1 documentation
pytorch.org › docs › stabletorch.max(input, dim, keepdim=False, *, out=None) Returns a namedtuple (values, indices) where values is the maximum value of each row of the input tensor in the given dimension dim. And indices is the index location of each maximum value found (argmax). If keepdim is True, the output tensors are of the same size as input except in the ...
Proper way to create tensor from scalars - PyTorch Forums
discuss.pytorch.org › t › proper-way-to-createDec 13, 2018 · Suppose I have a scalar tensor t which requires_grad and I would like to merge this into a larger tensor, for example: # Tensor created from scalar `t`; pseudo-code. M = [[ t**2 , sin(t) ], [ cos(t) , sqrt(t + 5) ]] Then the new tensor M is used to perform some computations and finally the gradients (w.r.t t) are computed by calling backward on the result. Right now I can think of two ways how ...