Python Pytorch full() method Last Updated : 22 Apr, 2020 Comments Improve Suggest changes Like Article Like Report 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.full() returns a tensor of size size filled with fill_value. Syntax: torch.ones(size, fill_value, out=None) Parameters: size: a sequence of integers defining the shape of the output tensor fill_value: the number to fill the output tensor with. out (Tensor, optional): the output tensor Return type: A tensor Code #1: Python3 # Importing the PyTorch library import torch # Applying the full function and # storing the resulting tensor in 'a' a = torch.full([3, 4], 3) print("a = ", a) b = torch.full([2, 5], 3.5) print("b = ", b) Output: a = tensor([[3., 3., 3., 3.], [3., 3., 3., 3.], [3., 3., 3., 3.]]) b = tensor([[3.5000, 3.5000, 3.5000, 3.5000, 3.5000], [3.5000, 3.5000, 3.5000, 3.5000, 3.5000]]) Comment More infoAdvertise with us Next Article Python Pytorch full() method S sanskar27jain 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 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 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 log2() method PyTorch log2() method computes the logarithm to the base 2 of the elements of an input tensor. Â It computes the logarithm values element-wise. Â It takes a tensor as an input and returns a new tensor with computed logarithm values. The elements of the input tensor must be between zero and the positiv 4 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 Like