参考 torch(七)、Math operations(1) - 云+社区 - 腾讯云
目录
torch.abs(input, out=None) → Tensor
torch.acos(input, out=None) → Tensor
torch.add(input, alpha=1, other, out=None)
out (Tensor, optional) – the output tensor.
torch.addcdiv(input, value=1, tensor1, tensor2, out=None) → Tensor
torch.addcmul(input, value=1, tensor1, tensor2, out=None) → Tensor
torch.asin(input, out=None) → Tensor
torch.atan(input, out=None) → Tensor
torch.atan2(input, other, out=None) → Tensor
torch.bitwise_not(input, out=None) → Tensor
torch.ceil(input, out=None) → Tensor
torch.clamp(input, min, max, out=None) → Tensor
torch.clamp(input, *, min, out=None) → Tensor
torch.clamp(input, *, max, out=None) → Tensor
torch.cos(input, out=None) → Tensor
torch.cosh(input, out=None) → Tensor
torch.div(input, other, out=None) → Tensor
torch.digamma(input, out=None) → Tensor
torch.erf(input, out=None) → Tensor
torch.erfc(input, out=None) → Tensor
torch.erfinv(input, out=None) → Tensor
torch.exp(input, out=None) → Tensor
torch.expm1(input, out=None) → Tensor
torch.floor(input, out=None) → Tensor
torch.fmod(input, other, out=None) → Tensor
torch.frac(input, out=None) → Tensor
torch.lerp(input, end, weight, out=None)
torch.log(input, out=None) → Tensor
torch.log10(input, out=None) → Tensor
torch.log1p(input, out=None) → Tensor
torch.log2(input, out=None) → Tensor
torch.logical_not(input, out=None) → Tensor
torch.logical_xor(input, other, out=None) → Tensor
torch.mul(input, other, out=None)
torch.mvlgamma(input, p) → Tensor
torch.neg(input, out=None) → Tensor
torch.pow(self, exponent, out=None) → Tensor
torch.reciprocal(input, out=None) → Tensor
torch.remainder(input, other, out=None) → Tensor
torch.round(input, out=None) → Tensor
torch.rsqrt(input, out=None) → Tensor
torch.sigmoid(input, out=None) → Tensor
torch.sign(input, out=None) → Tensor
torch.sin(input, out=None) → Tensor
torch.sinh(input, out=None) → Tensor
torch.sqrt(input, out=None) → Tensor
torch.tan(input, out=None) → Tensor
torch.tanh(input, out=None) → Tensor
torch.trunc(input, out=None) → Tensor
torch.argmax(input, dim, keepdim=False) → LongTensor
torch.argmin(input, dim, keepdim=False, out=None) → LongTensor
torch.cumprod(input, dim, out=None, dtype=None) → Tensor
torch.cumsum(input, dim, out=None, dtype=None) → Tensor
torch.dist(input, other, p=2) → Tensor
torch.logsumexp(input, dim, keepdim=False, out=None)
torch.mean(input, dim, keepdim=False, out=None) → Tensor
torch.median(input, dim=-1, keepdim=False, values=None, indices=None) -> (Tensor, LongTensor)
torch.mode(input, dim=-1, keepdim=False, values=None, indices=None) -> (Tensor, LongTensor)
torch.norm(input, p='fro', dim=None, keepdim=False, out=None, dtype=None)[source]
torch.prod(input, dim, keepdim=False, dtype=None) → Tensor
torch.std(input, dim, keepdim=False, unbiased=True, out=None) → Tensor
torch.std(input, dim, keepdim=False, unbiased=True) -> (Tensor, Tensor)
torch.sum(input, dim, keepdim=False, dtype=None) → Tensor
torch.unique(input, sorted=True, return_inverse=False, return_counts=False, dim=None)[source]
torch.unique_consecutive(input, return_inverse=False, return_counts=False, dim=None)[source]
torch.var(input, dim, keepdim=False, unbiased=True, out=None) → Tensor
torch.var_mean(input, dim, keepdim=False, unbiased=True) -> (Tensor, Tensor)
torch.allclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False) → bool
torch.argsort(input, dim=-1, descending=False, out=None) → LongTensor
torch.eq(input, other, out=None) → Tensor
torch.equal(input, other) → bool
torch.ge(input, other, out=None) → Tensor
torch.gt(input, other, out=None) → Tensor
torch.isfinite(tensor)[source]
tensor (Tensor) – A tensor to check
torch.kthvalue(input, k, dim=None, keepdim=False, out=None) -> (Tensor, LongTensor)
torch.le(input, other, out=None) → Tensor
torch.lt(input, other, out=None) → Tensor
torch.max(input, dim, keepdim=False, out=None) -> (Tensor, LongTensor)
torch.max(input, other, out=None) → Tensor
torch.min(input, dim, keepdim=False, out=None) -> (Tensor, LongTensor)
torch.min(input, other, out=None) → Tensor
torch.ne(input, other, out=None) → Tensor
torch.sort(input, dim=-1, descending=False, out=None) -> (Tensor, LongTensor)
torch.topk(input, k, dim=None, largest=True, sorted=True, out=None) -> (Tensor, LongTensor)
torch.abs(input, out=None) → TensorComputes the element-wise absolute value of the given input tensor.
outi=∣inputi∣\text{out}_{i} = |\text{input}_{i}| outi=∣inputi∣
Parameters
Example:
- >>> torch.abs(torch.tensor([-1, -2, 3]))
- tensor([ 1, 2, 3])
torch.acos(input, out=None) → TensorReturns a new tensor with the arccosine of the elements of input.
outi=cos−1(inputi)\text{out}_{i} = \cos^{-1}(\text{input}_{i}) outi=cos−1(inputi)
Parameters
Example:
- >>> a = torch.randn(4)
- >>> a
- tensor([ 0.3348, -0.5889, 0.2005, -0.1584])
- >>> torch.acos(a)
- tensor([ 1.2294, 2.2004, 1.3690, 1.7298])
torch.add()torch.add(input, other, out=None)
Adds the scalar other to each element of the input input and returns a new resulting tensor.
out=input+other\text{out} = \text{input} + \text{other} out=input+other
If input is of type FloatTensor or DoubleTensor, other must be a real number, otherwise it should be an integer.
Parameters
input (Tensor) – the input tensor.
value (Number) – the number to be added to each element of input
Keyword Arguments
out (Tensor, optional) – the output tensor.
Example:
- >>> a = torch.randn(4)
- >>> a
- tensor([ 0.0202, 1.0985, 1.3506, -0.6056])
- >>> torch.add(a, 20)
- tensor([ 20.0202, 21.0985, 21.3506, 19.3944])
torch.add(input, alpha=1, other, out=None)Each element of the tensor other is multiplied by the scalar alpha and added to each element of the tensor input. The resulting tensor is returned.
The shapes of input and other must be broadcastable.
out=input+alpha×other\text{out} = \text{input} + \text{alpha} \times \text{other} out=input+alpha×other
If other is of type FloatTensor or DoubleTensor, alpha must be a real number, otherwise it should be an integer.
Parameters
input (Tensor) – the first input tensor
alpha (Number) – the scalar multiplier for other
other (Tensor) – the second input tensor
Keyword Arguments
Example:
- >>> a = torch.randn(4)
- >>> a
- tensor([-0.9732, -0.3497, 0.6245, 0.4022])
- >>> b = torch.randn(4, 1)
- >>> b
- tensor([[ 0.3743],
- [-1.7724],
- [-0.5811],
- [-0.8017]])
- >>> torch.add(a, 10, b)
- tensor([[ 2.7695, 3.3930, 4.3672, 4.1450],
- [-18.6971, -18.0736, -17.0994, -17.3216],
- [ -6.7845, -6.1610, -5.1868, -5.4090],
- [ -8.9902, -8.3667, -7.3925, -7.6147]])
torch.addcdiv(input, value=1, tensor1, tensor2, out=None) → TensorPerforms the element-wise division of tensor1 by tensor2, multiply the result by the scalar value and add it to input.
outi=inputi+value×tensor1itensor2i\text{out}_i = \text{input}_i + \text{value} \times \frac{\text{tensor1}_i}{\text{tensor2}_i} outi=inputi+value×tensor2itensor1i
The shapes of input, tensor1, and tensor2 must be broadcastable.
For inputs of type FloatTensor or DoubleTensor, value must be a real number, otherwise an integer.
Parameters
input (Tensor) – the tensor to be added
value (Number, optional) – multiplier for tensor1/tensor2\text{tensor1} / \text{tensor2}tensor1/tensor2
tensor1 (Tensor) – the numerator tensor
tensor2 (Tensor) – the denominator tensor
out (Tensor, optional) – the output tensor.
Example:
- >>> t = torch.randn(1, 3)
- >>> t1 = torch.randn(3, 1)
- >>> t2 = torch.randn(1, 3)
- >>> torch.addcdiv(t, 0.1, t1, t2)
- tensor([[-0.2312, -3.6496, 0.1312],
- [-1.0428, 3.4292, -0.1030],
- [-0.5369, -0.9829, 0.0430]])
torch.addcmul(input, value=1, tensor1, tensor2, out=None) → TensorPerforms the element-wise multiplication of tensor1 by tensor2, multiply the result by the scalar value and add it to input.
outi=inputi+value×tensor1i×tensor2i\text{out}_i = \text{input}_i + \text{value} \times \text{tensor1}_i \times \text{tensor2}_i outi=inputi+value×tensor1i×tensor2i
The shapes of tensor, tensor1, and tensor2 must be broadcastable.
For inputs of type FloatTensor or DoubleTensor, value must be a real number, otherwise an integer.
Parameters
input (Tensor) – the tensor to be added
value (Number, optional) – multiplier for tensor1.∗tensor2tensor1 .* tensor2tensor1.∗tensor2
tensor1 (Tensor) – the tensor to be multiplied
tensor2 (Tensor) – the tensor to be multiplied
out (Tensor, optional) – the output tensor.
Example:
- >>> t = torch.randn(1, 3)
- >>> t1 = torch.randn(3, 1)
- >>> t2 = torch.randn(1, 3)
- >>> torch.addcmul(t, 0.1, t1, t2)
- tensor([[-0.8635, -0.6391, 1.6174],
- [-0.7617, -0.5879, 1.7388],
- [-0.8353, -0.6249, 1.6511]])
torch.asin(input, out=None) → TensorReturns a new tensor with the arcsine of the elements of input.
outi=sin−1(inputi)\text{out}_{i} = \sin^{-1}(\text{input}_{i}) outi=sin−1(inputi)
Parameters
Example:
- >>> a = torch.randn(4)
- >>> a
- tensor([-0.5962, 1.4985, -0.4396, 1.4525])
- >>> torch.asin(a)
- tensor([-0.6387, nan, -0.4552, nan])
torch.atan(input, out=None) → TensorReturns a new tensor with the arctangent of the elements of input.
outi=tan−1(inputi)\text{out}_{i} = \tan^{-1}(\text{input}_{i}) outi=tan−1(inputi)
Parameters
Example:
- >>> a = torch.randn(4)
- >>> a
- tensor([ 0.2341, 0.2539, -0.6256, -0.6448])
- >>> torch.atan(a)
- tensor([ 0.2299, 0.2487, -0.5591, -0.5727])
torch.atan2(input, other, out=None) → TensorElement-wise arctangent of inputi/otheri\text{input}_{i} / \text{other}_{i}inputi/otheri with consideration of the quadrant. Returns a new tensor with the signed angles in radians between vector (otheri,inputi)(\text{other}_{i}, \text{input}_{i})(otheri,inputi) and vector (1,0)(1, 0)(1,0) . (Note that otheri\text{other}_{i}otheri , the second parameter, is the x-coordinate, while inputi\text{input}_{i}inputi , the first parameter, is the y-coordinate.)
The shapes of input and other must be broadcastable.
Parameters
input (Tensor) – the first input tensor
other (Tensor) – the second input tensor
out (Tensor, optional) – the output tensor.
Example:
- >>> a = torch.randn(4)
- >>> a
- tensor([ 0.9041, 0.0196, -0.3108, -2.4423])
- >>> torch.atan2(a, torch.randn(4))
- tensor([ 0.9833, 0.0811, -1.9743, -1.4151])
torch.bitwise_not(input, out=None) → TensorComputes the bitwise NOT of the given input tensor. The input tensor must be of integral or Boolean types. For bool tensors, it computes the logical NOT.
Parameters
Example
- >>> torch.bitwise_not(torch.tensor([-1, -2, 3], dtype=torch.int8))
- tensor([ 0, 1, -4], dtype=torch.int8)
torch.ceil(input, out=None) → TensorReturns a new tensor with the ceil of the elements of input, the smallest integer greater than or equal to each element.
outi=⌈inputi⌉=⌊inputi⌋+1\text{out}_{i} = \left\lceil \text{input}_{i} \right\rceil = \left\lfloor \text{input}_{i} \right\rfloor + 1 outi=⌈inputi⌉=⌊inputi⌋+1
Parameters
Example:
- >>> a = torch.randn(4)
- >>> a
- tensor([-0.6341, -1.4208, -1.0900, 0.5826])
- >>> torch.ceil(a)
- tensor([-0., -1., -1., 1.])
torch.clamp(input, min, max, out=None) → TensorClamp all elements in input into the range [ min, max ] and return a resulting tensor:
yi={minif xi If Parameters input (Tensor) – the input tensor. min (Number) – lower-bound of the range to be clamped to max (Number) – upper-bound of the range to be clamped to out (Tensor, optional) – the output tensor. Example: Clamps all elements in If Parameters input (Tensor) – the input tensor. value (Number) – minimal value of each element in the output out (Tensor, optional) – the output tensor. Example: Clamps all elements in If Parameters input (Tensor) – the input tensor. value (Number) – maximal value of each element in the output out (Tensor, optional) – the output tensor. Example: Returns a new tensor with the cosine of the elements of outi=cos(inputi)\text{out}_{i} = \cos(\text{input}_{i}) outi=cos(inputi) Parameters Example: Returns a new tensor with the hyperbolic cosine of the elements of outi=cosh(inputi)\text{out}_{i} = \cosh(\text{input}_{i}) outi=cosh(inputi) Parameters Example: Divides each element of the input outi=inputiother\text{out}_i = \frac{\text{input}_i}{\text{other}} outi=otherinputi If Parameters {input} – other (Number) – the number to be divided to each element of {out} – Example: Each element of the tensor outi=inputiotheri\text{out}_i = \frac{\text{input}_i}{\text{other}_i} outi=otheriinputi Parameters input (Tensor) – the numerator tensor other (Tensor) – the denominator tensor out (Tensor, optional) – the output tensor. Example: Computes the logarithmic derivative of the gamma function on input. ψ(x)=ddxln(Γ(x))=Γ′(x)Γ(x)\psi(x) = \frac{d}{dx} \ln\left(\Gamma\left(x\right)\right) = \frac{\Gamma'(x)}{\Gamma(x)} ψ(x)=dxdln(Γ(x))=Γ(x)Γ′(x) Parameters input (Tensor) – the tensor to compute the digamma function on Example: Computes the error function of each element. The error function is defined as follows: erf(x)=2π∫0xe−t2dt\mathrm{erf}(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} dt erf(x)=π 2∫0xe−t2dt Parameters Example: Computes the complementary error function of each element of erfc(x)=1−2π∫0xe−t2dt\mathrm{erfc}(x) = 1 - \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} dt erfc(x)=1−π 2∫0xe−t2dt Parameters Example: Computes the inverse error function of each element of erfinv(erf(x))=x\mathrm{erfinv}(\mathrm{erf}(x)) = x erfinv(erf(x))=x Parameters Example: Returns a new tensor with the exponential of the elements of the input tensor yi=exiy_{i} = e^{x_{i}} yi=exi Parameters Example: Returns a new tensor with the exponential of the elements minus 1 of yi=exi−1y_{i} = e^{x_{i}} - 1 yi=exi−1 Parameters Example: Returns a new tensor with the floor of the elements of outi=⌊inputi⌋\text{out}_{i} = \left\lfloor \text{input}_{i} \right\rfloor outi=⌊inputi⌋ Parameters Example: Computes the element-wise remainder of division. The dividend and divisor may contain both for integer and floating point numbers. The remainder has the same sign as the dividend When Parameters input (Tensor) – the dividend other (Tensor or float) – the divisor, which may be either a number or a tensor of the same shape as the dividend out (Tensor, optional) – the output tensor. Example: Computes the fractional portion of each element in outi=inputi−⌊∣inputi∣⌋∗sgn(inputi)\text{out}_{i} = \text{input}_{i} - \left\lfloor |\text{input}_{i}| \right\rfloor * \operatorname{sgn}(\text{input}_{i}) outi=inputi−⌊∣inputi∣⌋∗sgn(inputi) Example: Does a linear interpolation of two tensors outi=starti+weighti×(endi−starti)\text{out}_i = \text{start}_i + \text{weight}_i \times (\text{end}_i - \text{start}_i) outi=starti+weighti×(endi−starti) The shapes of Parameters input (Tensor) – the tensor with the starting points end (Tensor) – the tensor with the ending points weight (float or tensor) – the weight for the interpolation formula out (Tensor, optional) – the output tensor. Example: Returns a new tensor with the natural logarithm of the elements of yi=loge(xi)y_{i} = \log_{e} (x_{i}) yi=loge(xi) Parameters Example: Returns a new tensor with the logarithm to the base 10 of the elements of yi=log10(xi)y_{i} = \log_{10} (x_{i}) yi=log10(xi) Parameters Example: Returns a new tensor with the natural logarithm of (1 + yi=loge(xi+1)y_i = \log_{e} (x_i + 1) yi=loge(xi+1) Note This function is more accurate than torch.log() for small values of Parameters Example: Returns a new tensor with the logarithm to the base 2 of the elements of yi=log2(xi)y_{i} = \log_{2} (x_{i}) yi=log2(xi) Parameters Example: Computes the element-wise logical NOT of the given input tensor. If not specified, the output tensor will have the bool dtype. If the input tensor is not a bool tensor, zeros are treated as Parameters Example: Computes the element-wise logical XOR of the given input tensors. Both input tensors must have the bool dtype. Parameters input (Tensor) – the input tensor. other (Tensor) – the tensor to compute XOR with out (Tensor, optional) – the output tensor. Example: Multiplies each element of the input outi=other×inputi\text{out}_i = \text{other} \times \text{input}_i outi=other×inputi If Parameters {input} – value (Number) – the number to be multiplied to each element of {out} – Example: Each element of the tensor The shapes of outi=inputi×otheri\text{out}_i = \text{input}_i \times \text{other}_i outi=inputi×otheri Parameters input (Tensor) – the first multiplicand tensor other (Tensor) – the second multiplicand tensor out (Tensor, optional) – the output tensor. Example: Computes the multivariate log-gamma function ([reference]) with dimension ppp element-wise, given by log(Γp(a))=C+∑i=1plog(Γ(a−i−12))\log(\Gamma_{p}(a)) = C + \displaystyle \sum_{i=1}^{p} \log\left(\Gamma\left(a - \frac{i - 1}{2}\right)\right) log(Γp(a))=C+i=1∑plog(Γ(a−2i−1)) where C=log(π)×p(p−1)4C = \log(\pi) \times \frac{p (p - 1)}{4}C=log(π)×4p(p−1) and Γ(⋅)\Gamma(\cdot)Γ(⋅) is the Gamma function. If any of the elements are less than or equal to p−12\frac{p - 1}{2}2p−1 , then an error is thrown. Parameters input (Tensor) – the tensor to compute the multivariate log-gamma function p (int) – the number of dimensions Example: Returns a new tensor with the negative of the elements of out=−1×input\text{out} = -1 \times \text{input} out=−1×input Parameters Example: Takes the power of each element in When outi=xiexponent\text{out}_i = x_i ^ \text{exponent} outi=xiexponent When outi=xiexponenti\text{out}_i = x_i ^ {\text{exponent}_i} outi=xiexponenti When Parameters input (Tensor) – the input tensor. exponent (float or tensor) – the exponent value out (Tensor, optional) – the output tensor. Example: The operation applied is: outi=selfexponenti\text{out}_i = \text{self} ^ {\text{exponent}_i} outi=selfexponenti Parameters self (float) – the scalar base value for the power operation exponent (Tensor) – the exponent tensor out (Tensor, optional) – the output tensor. Example: Returns a new tensor with the reciprocal of the elements of outi=1inputi\text{out}_{i} = \frac{1}{\text{input}_{i}} outi=inputi1 Parameters Example: Computes the element-wise remainder of division. The divisor and dividend may contain both for integer and floating point numbers. The remainder has the same sign as the divisor. When Parameters input (Tensor) – the dividend other (Tensor or float) – the divisor that may be either a number or a Tensor of the same shape as the dividend out (Tensor, optional) – the output tensor. Example: See also torch.fmod(), which computes the element-wise remainder of division equivalently to the C library function Returns a new tensor with each of the elements of Parameters Example: Returns a new tensor with the reciprocal of the square-root of each of the elements of outi=1inputi\text{out}_{i} = \frac{1}{\sqrt{\text{input}_{i}}} outi=inputi 1 Parameters Example: Returns a new tensor with the sigmoid of the elements of outi=11+e−inputi\text{out}_{i} = \frac{1}{1 + e^{-\text{input}_{i}}} outi=1+e−inputi1 Parameters Example: Returns a new tensor with the signs of the elements of outi=sgn(inputi)\text{out}_{i} = \operatorname{sgn}(\text{input}_{i}) outi=sgn(inputi) Parameters Example: Returns a new tensor with the sine of the elements of outi=sin(inputi)\text{out}_{i} = \sin(\text{input}_{i}) outi=sin(inputi) Parameters Example: Returns a new tensor with the hyperbolic sine of the elements of outi=sinh(inputi)\text{out}_{i} = \sinh(\text{input}_{i}) outi=sinh(inputi) Parameters Example: Returns a new tensor with the square-root of the elements of outi=inputi\text{out}_{i} = \sqrt{\text{input}_{i}} outi=inputi Parameters Example: Returns a new tensor with the tangent of the elements of outi=tan(inputi)\text{out}_{i} = \tan(\text{input}_{i}) outi=tan(inputi) Parameters Example: Returns a new tensor with the hyperbolic tangent of the elements of outi=tanh(inputi)\text{out}_{i} = \tanh(\text{input}_{i}) outi=tanh(inputi) Parameters Example: Returns a new tensor with the truncated integer values of the elements of Parameters Example: Returns the indices of the maximum value of all elements in the This is the second value returned by torch.max(). See its documentation for the exact semantics of this method. Parameters input (Tensor) – the input tensor. Example: Returns the indices of the maximum values of a tensor across a dimension. This is the second value returned by torch.max(). See its documentation for the exact semantics of this method. Parameters input (Tensor) – the input tensor. dim (int) – the dimension to reduce. If keepdim (bool) – whether the output tensor has Example: Returns the indices of the minimum value of all elements in the This is the second value returned by torch.min(). See its documentation for the exact semantics of this method. Parameters input (Tensor) – the input tensor. Example: Returns the indices of the minimum values of a tensor across a dimension. This is the second value returned by torch.min(). See its documentation for the exact semantics of this method. Parameters input (Tensor) – the input tensor. dim (int) – the dimension to reduce. If keepdim (bool) – whether the output tensor has Example: Returns the cumulative product of elements of For example, if yi=x1×x2×x3×⋯×xiy_i = x_1 \times x_2\times x_3\times \dots \times x_i yi=x1×x2×x3×⋯×xi Parameters input (Tensor) – the input tensor. dim (int) – the dimension to do the operation over dtype (torch.dtype, optional) – the desired data type of returned tensor. If specified, the input tensor is casted to out (Tensor, optional) – the output tensor. Example: Returns the cumulative sum of elements of For example, if yi=x1+x2+x3+⋯+xiy_i = x_1 + x_2 + x_3 + \dots + x_i yi=x1+x2+x3+⋯+xi Parameters input (Tensor) – the input tensor. dim (int) – the dimension to do the operation over dtype (torch.dtype, optional) – the desired data type of returned tensor. If specified, the input tensor is casted to out (Tensor, optional) – the output tensor. Example: Returns the p-norm of ( The shapes of Parameters input (Tensor) – the input tensor. other (Tensor) – the Right-hand-side input tensor p (float, optional) – the norm to be computed Example: Returns the log of summed exponentials of each row of the For summation index jjj given by dim and other indices iii , the result is logsumexp(x)i=log∑jexp(xij)\text{logsumexp}(x)_{i} = \log \sum_j \exp(x_{ij}) logsumexp(x)i=logj∑exp(xij) If Parameters input (Tensor) – the input tensor. dim (int or tuple of python:ints) – the dimension or dimensions to reduce. keepdim (bool) – whether the output tensor has out (Tensor, optional) – the output tensor. Example:: Returns the mean value of all elements in the Parameters input (Tensor) – the input tensor. Example: Returns the mean value of each row of the If Parameters input (Tensor) – the input tensor. dim (int or tuple of python:ints) – the dimension or dimensions to reduce. keepdim (bool) – whether the output tensor has out (Tensor, optional) – the output tensor. Example: Returns the median value of all elements in the Parameters input (Tensor) – the input tensor. Example: Returns a namedtuple By default, If Parameters input (Tensor) – the input tensor. dim (int) – the dimension to reduce. keepdim (bool) – whether the output tensor has values (Tensor, optional) – the output tensor indices (Tensor, optional) – the output index tensor Example: Returns a namedtuple By default, If Note This function is not defined for Parameters input (Tensor) – the input tensor. dim (int) – the dimension to reduce. keepdim (bool) – whether the output tensor has values (Tensor, optional) – the output tensor indices (Tensor, optional) – the output index tensor Example: Returns the matrix norm or vector norm of a given tensor. Parameters input (Tensor) – the input tensor p (int, float, inf, -inf, 'fro', 'nuc', optional) – the order of norm. Default: ord matrix norm vector norm None Frobenius norm 2-norm ’fro’ Frobenius norm – ‘nuc’ nuclear norm – Other as vec norm when dim is None sum(abs(x)**ord)**(1./ord) dim (int, 2-tuple of python:ints, 2-list of python:ints, optional) – If it is an int, vector norm will be calculated, if it is 2-tuple of ints, matrix norm will be calculated. If the value is None, matrix norm will be calculated when the input tensor only has two dimensions, vector norm will be calculated when the input tensor only has one dimension. If the input tensor has more than two dimensions, the vector norm will be applied to last dimension. keepdim (bool, optional) – whether the output tensors have out (Tensor, optional) – the output tensor. Ignored if dtype (torch.dtype, optional) – the desired data type of returned tensor. If specified, the input tensor is casted to :attr:’dtype’ while performing the operation. Default: None. Example: Returns the product of all elements in the Parameters input (Tensor) – the input tensor. dtype (torch.dtype, optional) – the desired data type of returned tensor. If specified, the input tensor is casted to Example: Returns the product of each row of the If Parameters input (Tensor) – the input tensor. dim (int) – the dimension to reduce. keepdim (bool) – whether the output tensor has dtype (torch.dtype, optional) – the desired data type of returned tensor. If specified, the input tensor is casted to Example: Returns the standard-deviation of all elements in the If Parameters Example: Returns the standard-deviation of each row of the If If Parameters input (Tensor) – the input tensor. dim (int or tuple of python:ints) – the dimension or dimensions to reduce. keepdim (bool) – whether the output tensor has unbiased (bool) – whether to use the unbiased estimation or not out (Tensor, optional) – the output tensor. Example: Returns the standard-deviation and mean of all elements in the If Parameters Example: Returns the standard-deviation and mean of each row of the If If Parameters input (Tensor) – the input tensor. dim (int or tuple of python:ints) – the dimension or dimensions to reduce. keepdim (bool) – whether the output tensor has unbiased (bool) – whether to use the unbiased estimation or not Example: Returns the sum of all elements in the Parameters input (Tensor) – the input tensor. dtype (torch.dtype, optional) – the desired data type of returned tensor. If specified, the input tensor is casted to Example: Returns the sum of each row of the If Parameters input (Tensor) – the input tensor. dim (int or tuple of python:ints) – the dimension or dimensions to reduce. keepdim (bool) – whether the output tensor has dtype (torch.dtype, optional) – the desired data type of returned tensor. If specified, the input tensor is casted to Example: Returns the unique elements of the input tensor. Parameters input (Tensor) – the input tensor sorted (bool) – Whether to sort the unique elements in ascending order before returning as output. return_inverse (bool) – Whether to also return the indices for where elements in the original input ended up in the returned unique list. return_counts (bool) – Whether to also return the counts for each unique element. dim (int) – the dimension to apply unique. If Returns A tensor or a tuple of tensors containing output (Tensor): the output list of unique scalar elements. inverse_indices (Tensor): (optional) if counts (Tensor): (optional) if Return type (Tensor, Tensor (optional), Tensor (optional)) Example: Eliminates all but the first element from every consecutive group of equivalent elements. Note This function is different from torch.unique() in the sense that this function only eliminates consecutive duplicate values. This semantics is similar to std::unique in C++. Parameters input (Tensor) – the input tensor return_inverse (bool) – Whether to also return the indices for where elements in the original input ended up in the returned unique list. return_counts (bool) – Whether to also return the counts for each unique element. dim (int) – the dimension to apply unique. If Returns A tensor or a tuple of tensors containing output (Tensor): the output list of unique scalar elements. inverse_indices (Tensor): (optional) if counts (Tensor): (optional) if Return type (Tensor, Tensor (optional), Tensor (optional)) Example: Returns the variance of all elements in the If Parameters Example: Returns the variance of each row of the If If Parameters input (Tensor) – the input tensor. dim (int or tuple of python:ints) – the dimension or dimensions to reduce. keepdim (bool) – whether the output tensor has unbiased (bool) – whether to use the unbiased estimation or not out (Tensor, optional) – the output tensor. Example: Returns the variance and mean of all elements in the If Parameters Example: Returns the variance and mean of each row of the If If Parameters input (Tensor) – the input tensor. dim (int or tuple of python:ints) – the dimension or dimensions to reduce. keepdim (bool) – whether the output tensor has unbiased (bool) – whether to use the unbiased estimation or not Example: This function checks if all ∣input−other∣≤atol+rtol×∣other∣\lvert \text{input} - \text{other} \rvert \leq \texttt{atol} + \texttt{rtol} \times \lvert \text{other} \rvert ∣input−other∣≤atol+rtol×∣other∣ elementwise, for all elements of Parameters input (Tensor) – first tensor to compare other (Tensor) – second tensor to compare atol (float, optional) – absolute tolerance. Default: 1e-08 rtol (float, optional) – relative tolerance. Default: 1e-05 equal_nan (bool, optional) – if Example: Returns the indices that sort a tensor along a given dimension in ascending order by value. This is the second value returned by torch.sort(). See its documentation for the exact semantics of this method. Parameters input (Tensor) – the input tensor. dim (int, optional) – the dimension to sort along descending (bool, optional) – controls the sorting order (ascending or descending) Example: Computes element-wise equality The second argument can be a number or a tensor whose shape is broadcastable with the first argument. Parameters input (Tensor) – the tensor to compare out (Tensor, optional) – the output tensor. Must be a ByteTensor Returns A Return type Example: Example: Computes input≥other\text{input} \geq \text{other}input≥other element-wise. The second argument can be a number or a tensor whose shape is broadcastable with the first argument. Parameters input (Tensor) – the tensor to compare out (Tensor, optional) – the output tensor that must be a BoolTensor Returns A Return type Example: Computes input>other\text{input} > \text{other}input>other element-wise. The second argument can be a number or a tensor whose shape is broadcastable with the first argument. Parameters input (Tensor) – the tensor to compare out (Tensor, optional) – the output tensor that must be a BoolTensor Returns A Return type Example: Returns a new tensor with boolean elements representing if each element is Finite or not. Parameters tensor (Tensor) – A tensor to check Returns Return type Example: Returns a new tensor with boolean elements representing if each element is +/-INF or not. Parameters Returns Return type Example: Returns a new tensor with boolean elements representing if each element is NaN or not. Parameters input (Tensor) – A tensor to check Returns A Return type Example: Returns a namedtuple If If Parameters input (Tensor) – the input tensor. k (int) – k for the k-th smallest element dim (int, optional) – the dimension to find the kth value along keepdim (bool) – whether the output tensor has out (tuple, optional) – the output tuple of (Tensor, LongTensor) can be optionally given to be used as output buffers Example: Computes input≤other\text{input} \leq \text{other}input≤other element-wise. The second argument can be a number or a tensor whose shape is broadcastable with the first argument. Parameters input (Tensor) – the tensor to compare out (Tensor, optional) – the output tensor that must be a BoolTensor Returns A Return type Example: Computes input The second argument can be a number or a tensor whose shape is broadcastable with the first argument. Parameters input (Tensor) – the tensor to compare out (Tensor, optional) – the output tensor that must be a BoolTensor Returns A torch.BoolTensor containing a True at each location where comparison is true Return type Example: Returns the maximum value of all elements in the Parameters {input} – Example: Returns a namedtuple If Parameters {input} – {dim} – Default ({keepdim}) – out (tuple, optional) – the result tuple of two output tensors (max, max_indices) Example: Each element of the tensor The shapes of outi=max(tensori,otheri)\text{out}_i = \max(\text{tensor}_i, \text{other}_i) outi=max(tensori,otheri) Note When the shapes do not match, the shape of the returned output tensor follows the broadcasting rules. Parameters input (Tensor) – the input tensor. other (Tensor) – the second input tensor out (Tensor, optional) – the output tensor. Example: Returns the minimum value of all elements in the Parameters {input} – Example: Returns a namedtuple If Parameters {input} – {dim} – {keepdim} – out (tuple, optional) – the tuple of two output tensors (min, min_indices) Example: Each element of the tensor The shapes of outi=min(tensori,otheri)\text{out}_i = \min(\text{tensor}_i, \text{other}_i) outi=min(tensori,otheri) Note When the shapes do not match, the shape of the returned output tensor follows the broadcasting rules. Parameters input (Tensor) – the input tensor. other (Tensor) – the second input tensor out (Tensor, optional) – the output tensor. Example: Computes input≠otherinput \neq otherinput=other element-wise. The second argument can be a number or a tensor whose shape is broadcastable with the first argument. Parameters input (Tensor) – the tensor to compare out (Tensor, optional) – the output tensor that must be a BoolTensor Returns A Return type Example: Sorts the elements of the If If A namedtuple of (values, indices) is returned, where the values are the sorted values and indices are the indices of the elements in the original input tensor. Parameters input (Tensor) – the input tensor. dim (int, optional) – the dimension to sort along descending (bool, optional) – controls the sorting order (ascending or descending) out (tuple, optional) – the output tuple of (Tensor, LongTensor) that can be optionally given to be used as output buffers Example: Returns the If If A namedtuple of (values, indices) is returned, where the indices are the indices of the elements in the original input tensor. The boolean option Parameters input (Tensor) – the input tensor. k (int) – the k in “top-k” dim (int, optional) – the dimension to sort along largest (bool, optional) – controls whether to return largest or smallest elements sorted (bool, optional) – controls whether to return the elements in sorted order out (tuple, optional) – the output tuple of (Tensor, LongTensor) that can be optionally given to be used as output buffersinput is of type FloatTensor or DoubleTensor, args min and max must be real numbers, otherwise they should be integers.torch.clamp(input, *, min, out=None) → Tensorinput to be larger or equal min.input is of type FloatTensor or DoubleTensor, value should be a real number, otherwise it should be an integer.torch.clamp(input, *, max, out=None) → Tensorinput to be smaller or equal max.input is of type FloatTensor or DoubleTensor, value should be a real number, otherwise it should be an integer.torch.cos(input, out=None) → Tensorinput.torch.cosh(input, out=None) → Tensorinput.torch.div()torch.div(input, other, out=None) → Tensorinput with the scalar other and returns a new resulting tensor.input is of type FloatTensor or DoubleTensor, other should be a real number, otherwise it should be an integerinputtorch.div(input, other, out=None) → Tensorinput is divided by each element of the tensor other. The resulting tensor is returned. The shapes of input and other must be broadcastable.torch.digamma(input, out=None) → Tensortorch.erf(input, out=None) → Tensortorch.erfc(input, out=None) → Tensorinput. The complementary error function is defined as follows:torch.erfinv(input, out=None) → Tensorinput. The inverse error function is defined in the range (−1,1)(-1, 1)(−1,1) as:torch.exp(input, out=None) → Tensorinput.torch.expm1(input, out=None) → Tensorinput.torch.floor(input, out=None) → Tensorinput, the largest integer less than or equal to each element.torch.fmod(input, other, out=None) → Tensorinput.other is a tensor, the shapes of input and other must be broadcastable.torch.frac(input, out=None) → Tensorinput.torch.lerp(input, end, weight, out=None)start (given by input) and end based on a scalar or tensor weight and returns the resulting out tensor.start and end must be broadcastable. If weight is a tensor, then the shapes of weight, start, and end must be broadcastable.torch.log(input, out=None) → Tensorinput.torch.log10(input, out=None) → Tensorinput.torch.log1p(input, out=None) → Tensorinput).inputtorch.log2(input, out=None) → Tensorinput.torch.logical_not(input, out=None) → TensorFalse and non-zeros are treated as True.torch.logical_xor(input, other, out=None) → Tensortorch.mul()torch.mul(input, other, out=None)input with the scalar other and returns a new resulting tensor.input is of type FloatTensor or DoubleTensor, other should be a real number, otherwise it should be an integerinputtorch.mul(input, other, out=None)input is multiplied by the corresponding element of the Tensor other. The resulting tensor is returned.input and other must be broadcastable.torch.mvlgamma(input, p) → Tensortorch.neg(input, out=None) → Tensorinput.torch.pow()torch.pow(input, exponent, out=None) → Tensorinput with exponent and returns a tensor with the result.exponent can be either a single float number or a Tensor with the same number of elements as input.exponent is a scalar value, the operation applied is:exponent is a tensor, the operation applied is:exponent is a tensor, the shapes of input and exponent must be broadcastable.torch.pow(self, exponent, out=None) → Tensorself is a scalar float value, and exponent is a tensor. The returned tensor out is of the same shape as exponenttorch.reciprocal(input, out=None) → Tensorinputtorch.remainder(input, other, out=None) → Tensorother is a tensor, the shapes of input and other must be broadcastable.fmod().torch.round(input, out=None) → Tensorinput rounded to the closest integer.torch.rsqrt(input, out=None) → Tensorinput.torch.sigmoid(input, out=None) → Tensorinput.torch.sign(input, out=None) → Tensorinput.torch.sin(input, out=None) → Tensorinput.torch.sinh(input, out=None) → Tensorinput.torch.sqrt(input, out=None) → Tensorinput.torch.tan(input, out=None) → Tensorinput.torch.tanh(input, out=None) → Tensorinput.torch.trunc(input, out=None) → Tensorinput.Reduction Ops
torch.argmax()torch.argmax(input) → LongTensorinput tensor.torch.argmax(input, dim, keepdim=False) → LongTensorNone, the argmax of the flattened input is returned.dim retained or not. Ignored if dim=None.torch.argmin()torch.argmin(input) → LongTensorinput tensor.torch.argmin(input, dim, keepdim=False, out=None) → LongTensorNone, the argmin of the flattened input is returned.dim retained or not. Ignored if dim=None.torch.cumprod(input, dim, out=None, dtype=None) → Tensorinput in the dimension dim.input is a vector of size N, the result will also be a vector of size N, with elements.dtype before the operation is performed. This is useful for preventing data type overflows. Default: None.torch.cumsum(input, dim, out=None, dtype=None) → Tensorinput in the dimension dim.input is a vector of size N, the result will also be a vector of size N, with elements.dtype before the operation is performed. This is useful for preventing data type overflows. Default: None.torch.dist(input, other, p=2) → Tensorinput - other)input and other must be broadcastable.torch.logsumexp(input, dim, keepdim=False, out=None)input tensor in the given dimension dim. The computation is numerically stabilized.
keepdim is True, the output tensor is of the same size as input except in the dimension(s) dim where it is of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensor having 1 (or len(dim)) fewer dimension(s).dim retained or not.torch.mean()torch.mean(input) → Tensorinput tensor.torch.mean(input, dim, keepdim=False, out=None) → Tensorinput tensor in the given dimension dim. If dim is a list of dimensions, reduce over all of them.keepdim is True, the output tensor is of the same size as input except in the dimension(s) dim where it is of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensor having 1 (or len(dim)) fewer dimension(s).dim retained or not.torch.median()torch.median(input) → Tensorinput tensor.torch.median(input, dim=-1, keepdim=False, values=None, indices=None) -> (Tensor, LongTensor)(values, indices) where values is the median value of each row of the input tensor in the given dimension dim. And indices is the index location of each median value found.dim is the last dimension of the input tensor.keepdim is True, the output tensors are of the same size as input except in the dimension dim where they are of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the outputs tensor having 1 fewer dimension than input.dim retained or not.torch.mode(input, dim=-1, keepdim=False, values=None, indices=None) -> (Tensor, LongTensor)(values, indices) where values is the mode value of each row of the input tensor in the given dimension dim, i.e. a value which appears most often in that row, and indices is the index location of each mode value found.dim is the last dimension of the input tensor.keepdim is True, the output tensors are of the same size as input except in the dimension dim where they are of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensors having 1 fewer dimension than input.torch.cuda.Tensor yet.dim retained or not.torch.norm(input, p='fro', dim=None, keepdim=False, out=None, dtype=None)[source]'fro' The following norms can be calculated: dim retained or not. Ignored if dim = None and out = None. Default: Falsedim = None and out = None.torch.prod()torch.prod(input, dtype=None) → Tensorinput tensor.dtype before the operation is performed. This is useful for preventing data type overflows. Default: None.torch.prod(input, dim, keepdim=False, dtype=None) → Tensorinput tensor in the given dimension dim.keepdim is True, the output tensor is of the same size as input except in the dimension dim where it is of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensor having 1 fewer dimension than input.dim retained or not.dtype before the operation is performed. This is useful for preventing data type overflows. Default: None.torch.std()torch.std(input, unbiased=True) → Tensorinput tensor.unbiased is False, then the standard-deviation will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.torch.std(input, dim, keepdim=False, unbiased=True, out=None) → Tensorinput tensor in the dimension dim. If dim is a list of dimensions, reduce over all of them.keepdim is True, the output tensor is of the same size as input except in the dimension(s) dim where it is of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensor having 1 (or len(dim)) fewer dimension(s).unbiased is False, then the standard-deviation will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.dim retained or not.torch.std_mean()torch.std_mean(input, unbiased=True) -> (Tensor, Tensor)input tensor.unbiased is False, then the standard-deviation will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.torch.std(input, dim, keepdim=False, unbiased=True) -> (Tensor, Tensor)input tensor in the dimension dim. If dim is a list of dimensions, reduce over all of them.keepdim is True, the output tensor is of the same size as input except in the dimension(s) dim where it is of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensor having 1 (or len(dim)) fewer dimension(s).unbiased is False, then the standard-deviation will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.dim retained or not.torch.sum()torch.sum(input, dtype=None) → Tensorinput tensor.dtype before the operation is performed. This is useful for preventing data type overflows. Default: None.torch.sum(input, dim, keepdim=False, dtype=None) → Tensorinput tensor in the given dimension dim. If dim is a list of dimensions, reduce over all of them.keepdim is True, the output tensor is of the same size as input except in the dimension(s) dim where it is of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensor having 1 (or len(dim)) fewer dimension(s).dim retained or not.dtype before the operation is performed. This is useful for preventing data type overflows. Default: None.torch.unique(input, sorted=True, return_inverse=False, return_counts=False, dim=None)[source]None, the unique of the flattened input is returned. default: None
return_inverse is True, there will be an additional returned tensor (same shape as input) representing the indices for where elements in the original input map to in the output; otherwise, this function will only return a single tensor.return_counts is True, there will be an additional returned tensor (same shape as output or output.size(dim), if dim was specified) representing the number of occurrences for each unique value or tensor.torch.unique_consecutive(input, return_inverse=False, return_counts=False, dim=None)[source]None, the unique of the flattened input is returned. default: None
return_inverse is True, there will be an additional returned tensor (same shape as input) representing the indices for where elements in the original input map to in the output; otherwise, this function will only return a single tensor.return_counts is True, there will be an additional returned tensor (same shape as output or output.size(dim), if dim was specified) representing the number of occurrences for each unique value or tensor.torch.var()torch.var(input, unbiased=True) → Tensorinput tensor.unbiased is False, then the variance will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.torch.var(input, dim, keepdim=False, unbiased=True, out=None) → Tensorinput tensor in the given dimension dim.keepdim is True, the output tensor is of the same size as input except in the dimension(s) dim where it is of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensor having 1 (or len(dim)) fewer dimension(s).unbiased is False, then the variance will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.dim retained or not.torch.var_mean()torch.var_mean(input, unbiased=True) -> (Tensor, Tensor)input tensor.unbiased is False, then the variance will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.torch.var_mean(input, dim, keepdim=False, unbiased=True) -> (Tensor, Tensor)input tensor in the given dimension dim.keepdim is True, the output tensor is of the same size as input except in the dimension(s) dim where it is of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensor having 1 (or len(dim)) fewer dimension(s).unbiased is False, then the variance will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.dim retained or not.Comparison Ops
torch.allclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False) → boolinput and other satisfy the condition:input and other. The behaviour of this function is analogous to numpy.allcloseTrue, then two NaN s will be compared as equal. Default: Falsetorch.argsort(input, dim=-1, descending=False, out=None) → LongTensortorch.eq(input, other, out=None) → Tensortorch.BoolTensor containing a True at each location where comparison is truetorch.equal(input, other) → boolTrue if two tensors have the same size and elements, False otherwise.torch.ge(input, other, out=None) → Tensortorch.BoolTensor containing a True at each location where comparison is truetorch.gt(input, other, out=None) → Tensortorch.BoolTensor containing a True at each location where comparison is truetorch.isfinite(tensor)[source]A torch.Tensor with dtype torch.bool containing a True at each location of finite elements and False otherwisetorch.isinf(tensor)[source]tensor (Tensor) – A tensor to check
A torch.Tensor with dtype torch.bool containing a True at each location of +/-INF elements and False otherwisetorch.isnan()torch.BoolTensor containing a True at each location of NaN elements.torch.kthvalue(input, k, dim=None, keepdim=False, out=None) -> (Tensor, LongTensor)(values, indices) where values is the k th smallest element of each row of the input tensor in the given dimension dim. And indices is the index location of each element found.dim is not given, the last dimension of the input is chosen.keepdim is True, both the values and indices tensors are the same size as input, except in the dimension dim where they are of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in both the values and indices tensors having 1 fewer dimension than the input tensor.dim retained or not.torch.le(input, other, out=None) → Tensortorch.BoolTensor containing a True at each location where comparison is truetorch.lt(input, other, out=None) → Tensortorch.max()torch.max(input) → Tensorinput tensor.torch.max(input, dim, keepdim=False, out=None) -> (Tensor, LongTensor)(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).keepdim is True, the output tensors are of the same size as input except in the dimension dim where they are of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensors having 1 fewer dimension than input.False.torch.max(input, other, out=None) → Tensorinput is compared with the corresponding element of the tensor other and an element-wise maximum is taken.input and other don’t need to match, but they must be broadcastable.torch.min()torch.min(input) → Tensorinput tensor.torch.min(input, dim, keepdim=False, out=None) -> (Tensor, LongTensor)(values, indices) where values is the minimum value of each row of the input tensor in the given dimension dim. And indices is the index location of each minimum value found (argmin).keepdim is True, the output tensors are of the same size as input except in the dimension dim where they are of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensors having 1 fewer dimension than input.torch.min(input, other, out=None) → Tensorinput is compared with the corresponding element of the tensor other and an element-wise minimum is taken. The resulting tensor is returned.input and other don’t need to match, but they must be broadcastable.torch.ne(input, other, out=None) → Tensortorch.BoolTensor containing a True at each location where comparison is true.torch.sort(input, dim=-1, descending=False, out=None) -> (Tensor, LongTensor)input tensor along a given dimension in ascending order by value.dim is not given, the last dimension of the input is chosen.descending is True then the elements are sorted in descending order by value.torch.topk(input, k, dim=None, largest=True, sorted=True, out=None) -> (Tensor, LongTensor)k largest elements of the given input tensor along a given dimension.dim is not given, the last dimension of the input is chosen.largest is False then the k smallest elements are returned.sorted if True, will make sure that the returned k elements are themselves sorted