您好,登錄后才能下訂單哦!
這篇文章主要介紹“torch.nn.SmoothL1Loss()和smooth_l1_loss()怎么使用”,在日常操作中,相信很多人在torch.nn.SmoothL1Loss()和smooth_l1_loss()怎么使用問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”torch.nn.SmoothL1Loss()和smooth_l1_loss()怎么使用”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
Microsoft Windows [版本 10.0.18363.1256](c) 2019 Microsoft Corporation。保留所有權(quá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>>> import torch.nn.functional as F>>> input = torch.zeros(2,3)>>> inputtensor([[0., 0., 0.],[0., 0., 0.]])>>> target = torch.tensor([[0.5,1.2,0.8],[0.4,1.5,2.2]])>>> target tensor([[0.5000, 1.2000, 0.8000],[0.4000, 1.5000, 2.2000]])>>>>>> F.smooth_l1_loss(target, input, size_average=False)D:\Anaconda3\envs\ssd4pytorch2_2_0\lib\site-packages\torch\nn\_reduction.py:43: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead. warnings.warn(warning.format(ret))tensor(3.9250)>>> F.smooth_l1_loss(target, input, size_average=True)D:\Anaconda3\envs\ssd4pytorch2_2_0\lib\site-packages\torch\nn\_reduction.py:43: UserWarning: size_average and reduce args will be deprecated, please use reduction='mean' instead. warnings.warn(warning.format(ret))tensor(0.6542)>>> 3.9250/6.00.6541666666666667>>>>>>>>>>>> F.smooth_l1_loss(target, input, reduction = 'sum')tensor(3.9250)>>>>>> F.smooth_l1_loss(target, input, reduction='mean')tensor(0.6542)>>>>>> F.smooth_l1_loss(target, input, reduction='none')tensor([[0.1250, 0.7000, 0.3200],[0.0800, 1.0000, 1.7000]])>>>>>> inputtensor([[0., 0., 0.],[0., 0., 0.]])>>> target tensor([[0.5000, 1.2000, 0.8000],[0.4000, 1.5000, 2.2000]])>>>>>>>>>
到此,關(guān)于“torch.nn.SmoothL1Loss()和smooth_l1_loss()怎么使用”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。