Python - PyTorch is_storage() method Last Updated : 26 May, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 PyTorch library import torch # A constant tensor of size n a = torch.FloatStorage(6) print(a) # Applying the is_tensor function and # storing the result in 'out' out = torch.is_storage(a) print(out) Output: -30587.265625 4.555761437366413e-41 3.906847023468105e-37 0.0 4.484155085839415e-44 0.0 [torch.FloatStorage of size 6] True Example 2: Python3 # Importing the PyTorch library import torch # A constant tensor of size n a = torch.randn(4, 6) print(a) # Applying the is_tensor function and # storing the result in 'out' out = torch.is_storage(a) print(out) Output: 0.4837 -0.3108 0.5945 -0.5967 1.0831 0.0967 -0.0174 0.4937 0.9900 -0.0532 -0.4830 -0.4711 1.3607 -1.0815 0.4421 -0.2668 -0.5778 -0.0482 -2.0869 -0.8338 1.2260 -0.8849 0.7303 -1.0050 [torch.FloatTensor of size 4x6] False Comment More infoAdvertise with us Next Article Python - PyTorch numel() method P PranchalKatiyar Follow Improve Article Tags : Python Python-PyTorch Practice Tags : python Similar Reads Python - PyTorch is_tensor() method PyTorch torch.is_tensor() method returns True if the passed object is a PyTorch tensor. Syntax: torch.is_tensor(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 t 1 min read Tensor.detach() Method in Python PyTorch In this article, we will see Tensor.detach() method in PyTorch using Python. Pytorch is a Python and C++ interface for an open-source deep learning platform. It is found within the torch module. In PyTorch, the input data has to be processed in the form of a tensor. It also includes a module that ca 2 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 empty() 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.empty() returns a tensor filled with uninitialized data. The shape of the tensor is defined by the variable argument size. Syntax: 1 min read Python - PyTorch numel() method PyTorch torch.numel() method returns the total number of elements in the input tensor. Syntax: torch.numel(input) Arguments input: This is input tensor. Return: It returns the length of the input tensor. Let's see this concept with the help of few examples: Example 1: Python3 # Importing the PyTorch 1 min read How Does the "View" Method Work in Python PyTorch? PyTorch, a popular open-source machine learning library, is known for its dynamic computational graphs and intuitive interface, particularly when it comes to tensor operations. One of the most commonly used tensor operations in PyTorch is the .view() function. If you're working with PyTorch, underst 5 min read Like