Python - PyTorch abs() method Last Updated : 26 May, 2020 Comments Improve Suggest changes Like Article Like Report PyTorch torch.abs() method computes the element-wise absolute value of the given input tensor. Syntax: torch.abs(inp, out=None) ? Tensor Arguments inp: This is input tensor. out: This is optional parameter and is the output tensor. Return: It returns a Tensor having absolute value of input inp. Let's see this concept with the help of few examples: Example 1: Python3 # Importing the PyTorch library import torch # A constant tensor of size 1 a = torch.FloatTensor([-15]) print(a) # Applying the abs function and # storing the result in 'b' b = torch.abs(a) print(b) Output: -15 [torch.FloatTensor of size 1] 15 [torch.FloatTensor of size 1] Example 2: Python3 # Importing the PyTorch library import torch # A constant tensor of size n a = torch.FloatTensor([15, -5, 3, -2]) print(a) # Applying the abs function and # storing the result in 'b' b = torch.abs(a) print(b) Output: 15 -5 3 -2 [torch.FloatTensor of size 4] 15 5 3 2 [torch.FloatTensor of size 4] Comment More infoAdvertise with us Next Article Python - PyTorch abs() method P PranchalKatiyar Follow Improve Article Tags : Python Python-PyTorch Practice Tags : python Similar Reads Python | PyTorch asin() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes.The function torch.asin() provides support for the inverse sine function in PyTorch. It expects the input to be in the range [-1, 1] and gives the out 2 min read Python | PyTorch acos() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes. The function torch.acos() provides support for the inverse cosine function in PyTorch. It expects the input to be in the range [-1, 1] and gives the 2 min read Python | PyTorch cos() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes.The function torch.cos() provides support for the cosine function in PyTorch. It expects the input in radian form and the output is in the range [-1, 2 min read Python - PyTorch frac() method PyTorch torch.frac() method computes the fractional portion of each element in input. Syntax: torch.frac(input, out=None) Arguments input: This is input tensor. out: The output tensor. Return: It returns a Tensor. Let's see this concept with the help of few examples: Example 1: Python3 # Importing t 1 min read Python | PyTorch atan() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes. The function torch.atan() provides support for the inverse tangent function in PyTorch. It gives the output in radian form. The input type is tensor 2 min read Python | PyTorch cosh() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes. The function torch.cosh() provides support for the hyperbolic cosine function in PyTorch. It expects the input in radian form. The input type is tens 2 min read Python - PyTorch clamp() method PyTorch torch.clamp() method clamps all the input elements into the range [ min, max ] and return a resulting tensor. Syntax: torch.clamp(inp, min, max, out=None) Arguments inp: This is input tensor. min: This is a number and specifies the lower-bound of the range to which input to be clamped. max: 2 min read Python - PyTorch floor() method PyTorch torch.floor() method returns a new tensor which is floor of the elements of input, the largest integer less than or equal to each element. Syntax: torch.floor(input, out=None) Arguments input: This is input tensor. out: The output tensor. Return: It returns a Tensor. Let's see this concept w 1 min read Python | PyTorch sin() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes. The function torch.sin() provides support for the sine function in PyTorch. It expects the input in radian form and the output is in the range [-1, 1 2 min read Python | PyTorch tan() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes. The function torch.tan() provides support for the tangent function in PyTorch. It expects the input in radian form and the output is in the range [-â 2 min read Like