当前位置:网站首页>The difference between torch.nn and torch.nn.functional in pytorch
The difference between torch.nn and torch.nn.functional in pytorch
2022-07-26 14:45:00 【The way of code】
torch.nn
pytorch Chinese document links :torch.nn
stay __init__() The function defines , It defines a class :
torch.nn.functional
pytorch Chinese document links :torch.nn.functional
stay __forward()__ The function defines , What is defined is a function :
The difference between the two
torch.nn Is a defined class , With class xx To define the , You can extract varying learning parameters .
torch.nn.functional It's a function , from def function( ) Definition , Is a fixed formula .
In the deep learning, there will be many weights that are constantly updated , So we need to adopt the method of class , To ensure that we can still use the operation steps we set before when the parameters change . So if the model has learnable parameters , You should use nn.Module, Otherwise there is no difference between the two . But simple calculation does not need to create a new class to do , So use nn.functional Define a function .
namely : Within the layer variable For nn Definition , Otherwise, use nn.functional Definition .
Learn more about programming , Please pay attention to my official account :

边栏推荐
- llcc68广播唤醒简单说明
- 1-to-1 live broadcast source code - 1-to-1 voice chat source code
- Self encoder AE (autoencoder) program
- Low power multi-channel wfas1431 wireless data acquisition and transmission instrument operation process description
- 《MySQL高级篇》五、InnoDB数据存储结构
- SP export map to Maya
- VBA 上传图片
- AMB | towards sustainable agriculture: rhizosphere microbial engineering
- Win11运行虚拟机死机了?Win11运行VMware虚拟机崩溃的解决方法
- Unity学习笔记–无限地图
猜你喜欢
随机推荐
Install dexdump on win10 and remove the shell
As the "first city" in Central China, Changsha's "talent attraction" has changed from competition to leadership
[Yugong series] July 2022 go teaching course 017 - if of branch structure
TDengine 助力西门子轻量级数字化解决方案 SIMICAS 简化数据处理流程
Mysql-03 database operation
自编码器 AE(AutoEncoder)程序
Summary and analysis of image level weakly supervised image semantic segmentation
Winscp transfer file and VNC connection problem
网络图片转本地导致内核退出
Transc knowledge representation model
GOM login configuration free version generate graphic tutorial
Low power multi-channel wfas1431 wireless data acquisition and transmission instrument operation process description
C# 常用功能整合
postman 环境变量设置代码存放
Win11运行虚拟机死机了?Win11运行VMware虚拟机崩溃的解决方法
UE4 smart pointer and weak pointer
GOM登录器配置免费版生成图文教程
selenium 代码存放
键盘快捷键操作电脑(自己遇到不会的)
Fill in the questionnaire and receive the prize | we sincerely invite you to fill in the Google play academy activity survey questionnaire







![[draw with toolbar]](/img/d4/9cb06599f9a8fe5f8149cb7870c103.png)

![[GYCTF2020]FlaskApp](/img/ee/dcb42617af4a0e41657f6cf7095feb.png)