Python torch.numel(input)怎么使用

本篇内容主要讲解“Python torch.numel(input)怎么使用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Python torch.numel(input)怎么使用”吧!

函数使用说明:
	torch.numel(input) → int
	返回输入张量input的元素总数
Microsoft Windows [版本 10.0.18363.1256](c) 2019 Microsoft Corporation。保留所有权利。

C:\Users\chenxuqi>conda activate ssd4pytorch2_2_0(ssd4pytorch2_2_0) C:\Users\chenxuqi>python
Python 3.7.7 (default, May  6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.>>> import torch>>> torch.manual_seed(seed=20200910)<torch._C.Generator object at 0x0000021CCA53D330>>>>>>> a = torch.randn(1, 2, 3, 4, 5)>>> a.numel()120>>> torch.numel(a)120>>>>>>>>> a = torch.zeros(4,4)>>> a.numel()16>>>>>>>>> torch.numel(a)16>>>>>>>>>

到此,相信大家对“Python torch.numel(input)怎么使用”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!