您好,登錄后才能下訂單哦!
這篇文章主要講解了“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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。