Python - PyTorch fmod() method Last Updated : 26 May, 2020 Comments Improve Suggest changes Like Article Like Report 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. 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, 6, 7, 4]) print(a) # Applying the fmod function and # storing the result in 'out' out = torch.fmod(a, 3) print(out) Output: 5 6 7 4 [torch.FloatTensor of size 4] 2 0 1 1 [torch.FloatTensor of size 4] Example 2: Python3 # Importing the PyTorch library import torch # A constant tensor of size n a = torch.FloatTensor([5, 6, 7, 4]) b = torch.FloatTensor([2, 3, 4, 1]) print(a, b) # Applying the fmod function and # storing the result in 'out' out = torch.fmod(a, b) print(out) Output: 5 6 7 4 [torch.FloatTensor of size 4] 2 3 4 1 [torch.FloatTensor of size 4] 1 0 3 0 [torch.FloatTensor of size 4] Comment More infoAdvertise with us Next Article Python - PyTorch fmod() 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 add() method PyTorch torch.add() method adds a constant value to each element of the input tensor and returns a new modified tensor. Syntax: torch.add(inp, c, out=None) Arguments inp: This is input tensor. c: The value that is to be added to every element of tensor. out: This is optional parameter and it is the 1 min read Python - PyTorch log() method PyTorch torch.log() method gives a new tensor having the natural logarithm of the elements of input tensor. Syntax: torch.log(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: 1 min read Python - PyTorch div() method PyTorch torch.div() method divides every element of the input with a constant and returns a new modified tensor. Syntax: torch.div(inp, other, out=None) Arguments inp: This is input tensor. other: This is a number to be divided to each element of input inp. out: The output tensor. Return: It returns 1 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 Like