Python - PyTorch div() method Last Updated : 26 May, 2020 Comments Improve Suggest changes Like Article Like Report 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 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([1, 4, 6, 8, 10, 14]) print(a) # Applying the div function and # storing the result in 'out' out = torch.div(a, 0.5) print(out) Output: 1 4 6 8 10 14 [torch.FloatTensor of size 6] 2 8 12 16 20 28 [torch.FloatTensor of size 6] Example 2: Python3 # Importing the PyTorch library import torch # A constant tensor of size n a = torch.randn(6) print(a) # Applying the div function and # storing the result in 'out' out = torch.div(a, 0.3) print(out) Output: -0.8453 -0.1101 0.9431 -0.3041 1.4305 -0.0390 [torch.FloatTensor of size 6] -2.8176 -0.3669 3.1436 -1.0137 4.7683 -0.1300 [torch.FloatTensor of size 6] Comment More infoAdvertise with us Next Article Python - PyTorch div() method P PranchalKatiyar Follow Improve Article Tags : Python Python-PyTorch Practice Tags : python Similar Reads 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 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 ceil() method PyTorch torch.ceil() method returns a new tensor having the ceil value of the elements of input, Which is the smallest integer larger than or equal to each element. Syntax: torch.ceil(inp, out=None) Arguments inp: This is input tensor. out: The output tensor. Return: It returns a Tensor. Let's see t 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 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 Like