1''' PyTorch torch.numel() method returns the total
2number of elements in the input tensor.'''
3# Importing the PyTorch library
4import torch
5
6# A constant tensor of size n
7a = torch.randn(4, 6)
8print(a)
9
10# Applying the numel function and
11# storing the result in 'out'
12out = torch.numel(a)
13print(out)
14
15>>>-0.8263 0.9807 -1.4688 0.2117 -0.8356 -0.0228
16-0.8815 1.3652 -0.1892 -1.1241 0.2755 1.3006
17 0.0559 0.2389 0.7944 2.6587 -2.0908 1.2973
18-0.2056 0.4110 0.2163 0.3091 0.5559 -0.2468
19[torch.FloatTensor of size 4x6]
2024