Python Pytorch empty() method Last Updated : 22 Apr, 2020 Summarize Comments Improve Suggest changes Share 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.empty() returns a tensor filled with uninitialized data. The shape of the tensor is defined by the variable argument size. Syntax: torch.empty(size, out=None) Parameters: size: a sequence of integers defining the shape of the output tensor out (Tensor, optional): the output tensor Return type: A tensor Code #1: Python3 # Importing the PyTorch library import torch # Applying the empty function and # storing the resulting tensor in 'a' a = torch.empty([3, 4]) print("a = ", a) b = torch.empty([2, 3]) print("b = ", b) Output: a = tensor([[2.0283e-19, 6.9772e+22, 1.8943e+23, 1.1432e-32], [1.3563e-19, 1.8888e+31, 8.9066e-15, 1.8888e+31], [6.4639e-04, 6.8608e+22, 1.7753e+28, 2.0535e-19]]) b = tensor([[0., 0., 0.], [0., 0., 0.]]) Comment More infoAdvertise with us Next Article Python Pytorch empty() method S sanskar27jain Follow Improve Article Tags : Python Python-PyTorch Practice Tags : python Similar Reads Python PyTorch zeros() 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.zeros() returns a tensor filled with the scalar value 0, with the shape defined by the variable argument size. Syntax: torch.zeros 1 min read Python - PyTorch is_storage() method PyTorch torch.is_storage() method returns True if obj is a PyTorch storage object. Syntax: torch.is_storage(object) Arguments object: This is input tensor to be tested. Return: It returns either True or False. Let's see this concept with the help of few examples: Example 1: Python3 # Importing the P 1 min read Python - PyTorch is_storage() method PyTorch torch.is_storage() method returns True if obj is a PyTorch storage object. Syntax: torch.is_storage(object) Arguments object: This is input tensor to be tested. Return: It returns either True or False. Let's see this concept with the help of few examples: Example 1: Python3 # Importing the P 1 min read Python Set clear() Method Python Set clear() method removes all elements from the set. Python Set clear() Method Syntax: Syntax: set.clear() parameters: The clear() method doesn't take any parameters. Â Return: None Time complexity : The time complexity of set.clear() function on a set with n element is O(n) . Example 1: Pyth 2 min read Python | getattr() method The getattr() method in Python returns the value of a named attribute of an object. If the attribute is not found then it returns the default value provided. If no default is given and the attribute does not exist then it raises an AttributeError.Python getattr() Method SyntaxSyntax : getattr(obj, k 3 min read Like