Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use torch.nn.SmoothL1Loss () and smooth_l1_loss ()

Shulou Source: shulou.com Published: 2022-06-01 07:54:36 10月05日 Update

This article mainly introduces "how to use torch.nn.SmoothL1Loss () and smooth_l1_loss ()". In daily operation, I believe many people have doubts about how to use torch.nn.SmoothL1Loss () and smooth_l1_loss (). The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use torch.nn.SmoothL1Loss () and smooth_l1_loss ()". Next, please follow the editor to study!

Microsoft Windows [version 10.0.18363.1256] (c) 2019 Microsoft Corporation. All rights reserved. C:\ Users\ chenxuqi > conda activate ssd4pytorch2_2_0 (ssd4pytorch2_2_0) C:\ Users\ chenxuqi > pythonPython 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)]:: Anaconda, Inc. On win32Type "help", "copyright", "credits" or "license" for more information. > import torch > > import torch.nn.functional as F > > input = torch.zeros (2Yue3) > > inputtensor ([[0.,0.,0.], [0.,0.], [0.,0. 0.]]) > target = torch.tensor ([[0.5000, 1.2000, 0.8000], [0.4000, 1.5000, 2.2000]]) > > targettensor > 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.9250max 6.00.654166666666666667 > 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.]) > > targettensor ([[0.5000, 1.2000, 0.8000], [0.4000, 1.5000, 2.2000]]) > so far The study on "how to use torch.nn.SmoothL1Loss () and smooth_l1_loss ()" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Learning more help practical next articles methods rights versions theories knowledge articles websites materials follow questions easy to use practice solutions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Huawei Shulou Tech Info vpn Linux