Python - PyTorch frac() method Last Updated : 26 May, 2020 Comments Improve Suggest changes Like Article Like Report 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 the PyTorch library import torch # A constant tensor of size n a = torch.FloatTensor([-5.4, 6.6, -7.1099, 4.4567]) print(a) # Applying the frac function and # storing the result in 'out' out = torch.frac(a) print(out) Output: -5.4000 6.6000 -7.1099 4.4567 [torch.FloatTensor of size 4] -0.4000 0.6000 -0.1099 0.4567 [torch.FloatTensor of size 4] Example 2: Python3 # Importing the PyTorch library import torch # A constant tensor of size n a = torch.randn(6) print(a) # Applying the frac function and # storing the result in 'out' out = torch.frac(a) print(out) Output: -0.5260 -1.8843 0.8062 1.2264 -0.1505 -0.3217 [torch.FloatTensor of size 6] -0.5260 -0.8843 0.8062 0.2264 -0.1505 -0.3217 [torch.FloatTensor of size 6] Comment More infoAdvertise with us Next Article Python - PyTorch frac() method P PranchalKatiyar Follow Improve Article Tags : Python Python-PyTorch Practice Tags : python Similar Reads 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 abs() method 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' 1 min read Python - PyTorch fmod() method PyTorch torch.fmod() method gives the element-wise remainder of division by divisor. The divisor may be a number or a Tensor. Syntax: torch.fmod(input, div, out=None) Arguments input: This is input tensor. div: This may be a number or a tensor. out: The output tensor. Return: It returns a Tensor. Le 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 Like