这篇文章主要讲解了“PyTorch的class torch.nn.Sigmoid怎么使用”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“PyTorch的class torch.nn.Sigmoid怎么使用”吧!
代码实验展示:
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 0x000001D44FE2D330>>>>>>> data = torch.randn(3,5)>>> data tensor([[ 0.2824, -0.3715, 0.9088, -1.7601, -0.1806],[ 2.0937, 1.0406, -1.7651, 1.1216, 0.8440],[ 0.1783, 0.6859, -1.5942, -0.2006, -0.4050]])>>> data[0,1] = 0.0>>> data tensor([[ 0.2824, 0.0000, 0.9088, -1.7601, -0.1806],[ 2.0937, 1.0406, -1.7651, 1.1216, 0.8440],[ 0.1783, 0.6859, -1.5942, -0.2006, -0.4050]])>>>>>> torch.nn.functional.sigmoid(data)D:\Anaconda3\envs\ssd4pytorch2_2_0\lib\site-packages\torch\nn\functional.py:1350: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead. warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")tensor([[0.5701, 0.5000, 0.7127, 0.1468, 0.4550],[0.8903, 0.7390, 0.1461, 0.7543, 0.6993],[0.5445, 0.6650, 0.1688, 0.4500, 0.4001]])>>>>>>>>> model = torch.nn.Sigmoid()>>> model(data)tensor([[0.5701, 0.5000, 0.7127, 0.1468, 0.4550],[0.8903, 0.7390, 0.1461, 0.7543, 0.6993],[0.5445, 0.6650, 0.1688, 0.4500, 0.4001]])>>>>>>
感谢各位的阅读,以上就是“PyTorch的class torch.nn.Sigmoid怎么使用”的内容了,经过本文的学习后,相信大家对PyTorch的class torch.nn.Sigmoid怎么使用这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。