HomeLanguagesPython – PyTorch is_storage() method

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:




# 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:




# 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
Last Updated :
26 May, 2020
Like Article
Save Article

<!–

–>

Similar Reads
Related Tutorials
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32715 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7092 POSTS0 COMMENTS
Nicole Veronica
12231 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12313 POSTS0 COMMENTS
Shaida Kate Naidoo
7209 POSTS0 COMMENTS
Ted Musemwa
7473 POSTS0 COMMENTS
Thapelo Manthata
7192 POSTS0 COMMENTS
Umr Jansen
7173 POSTS0 COMMENTS