這篇文章主要講解了“PyTorch的class torch.nn.Sigmoid怎么使用”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“PyTorch的class torch.nn.Sigmoid怎么使用”吧!
成都創(chuàng)新互聯(lián)專注于企業(yè)營銷型網(wǎng)站、網(wǎng)站重做改版、師宗網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、HTML5建站、商城網(wǎng)站定制開發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)公司、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為師宗等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
代碼實(shí)驗(yàn)展示:
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)>>>>>> 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怎么使用”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)PyTorch的class torch.nn.Sigmoid怎么使用這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!