Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use torch.nn.Linear () and torch.nn.functional.linear ()

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article to share with you is about torch.nn.Linear() and torch.nn.functional.linear() how to use, Xiaobian think quite practical, so share with you to learn, I hope you can read this article after some harvest, not much to say, follow Xiaobian to see it.

Code Lab Showcase:

Microsoft Windows [version 10.0.18363.1316](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 as nn>>> import torch.nn.functional as F>>> torch.manual_seed (seed=20200910)>>>>>> data_in = torch.randn (3,4,5,6,7)>>> data_in.shapetorch.Size ([3, 4, 5, 6, 7])>>> linear4cxq = nn.Linear(7, 30)>>>>>> linear4cxqLinear (in_features=7, out_features=30, bias=True)>>>>>> data_out = linear4cxq(data_in)>>> data_out.shapetorch.Size ([3, 4, 5, 6, 30])>>>>>> data_in.shapetorch.Size([3, 4, 5, 6, 7])>>>>>>>>> I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report