Python - PyTorch is_tensor() method Last Updated : 26 May, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 the PyTorch library import torch # A constant tensor of size n a = torch.FloatTensor([1, 4, 6, 9]) print(a) # Applying the is_tensor function and # storing the result in 'out' out = torch.is_tensor(a) print(out) Output: 1 4 6 9 [torch.FloatTensor of size 4] 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_tensor(a) print(out) Output: 0.7491 -1.5987 -0.9733 0.0436 -0.3093 2.0007 0.5679 -0.0092 -0.2573 0.9173 2.9849 -2.0159 -1.9215 -0.9131 -0.8244 0.4160 -0.3855 0.7033 1.7367 -1.1454 -1.4369 -0.9856 -0.9076 0.6267 [torch.FloatTensor of size 4x6] True Comment More infoAdvertise with us Next Article Python - PyTorch is_tensor() method P PranchalKatiyar Follow Improve Article Tags : Python Python-PyTorch Practice Tags : python Similar Reads 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 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 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 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 Like