当前位置:网站首页>PyTorch中的Sequential、ModuleList和ModuleDict用法总结
PyTorch中的Sequential、ModuleList和ModuleDict用法总结
2022-06-12 03:33:00 【AI视觉网奇】
以下内容转自:
PyTorch中的Sequential、ModuleList和ModuleDict用法总结_非晚非晚的博客-CSDN博客
1. 区别与联系
首先来一张图,总体概括一下它们的区别:

区别
nn.Sequential内部实现了forward函数,因此可以不用写forward函数。而nn.ModuleList和nn.ModuleDict则没有实现内部forward函数。
nn.Sequential需要严格按照顺序执行,而其它两个模块则可以任意调用。
下面分别进行介绍。
1.1 nn.Sequential 不能自由添加删除
nn.Sequential里面的模块按照顺序进行排列的,所以必须确保前一个模块的输出大小和下一个模块的输入大小是一致的,不能自由添加,删除。
nn.Sequential中可以使用OrderedDict来指定每个module的名字。
1.2
边栏推荐
- Special information | liquor (Baijiu, beer, wine)
- Recommend 6 office software, easy to use and free, double the efficiency
- 微服务概念及介绍
- PostMessage implements window communication
- Paper recommendation: relicv2, can the new self supervised learning surpass supervised learning on RESNET?
- 微信小程序项目实例——体质计算器
- Unity3d ugui translucent or linear gradient pictures display abnormally (blurred) problem solving (color space mismatch)
- [mysql][mysql 8.0 compressed package installation method]
- 微信小程序项目实例——我有一支画笔(画画)
- TCP three handshakes and four waves
猜你喜欢

Demand and business model innovation - demand 9- prototype

What is the core of Web3?
![[C language] dynamic memory allocation](/img/ac/ba3882c76f93dde0ab0d5294c5b6d9.jpg)
[C language] dynamic memory allocation

顺序表与链表---初阶

Recommend 6 office software, easy to use and free, double the efficiency

MySQL partition table create delete modify view
![[Hongmeng] use the timer to play a simple game of robbing red envelopes](/img/27/32b65dc90db7f6ece24ad39ff9b0ef.png)
[Hongmeng] use the timer to play a simple game of robbing red envelopes

The road of global evolution of vivo global mall -- multilingual solution

(idea)the file size(2.85M) exceeds configured limit(2.56M). Code insight features are not available
![What is a request response pair called? [repeat] - what is a request response pair called? [duplicate]](/img/65/a214d137e230b1a1190feb03660f2c.jpg)
What is a request response pair called? [repeat] - what is a request response pair called? [duplicate]
随机推荐
MySQL的check约束数字问题
VIM command Encyclopedia
【鸿蒙】 使用定时器做一个简单的抢红包小游戏
根据变换矩阵进行图像拼接
What is a request response pair called? [repeat] - what is a request response pair called? [duplicate]
Detailed explanation of data platform SQL development and function use
Review of technical economy and Enterprise Management Chapter 4
Laravel 8 selects JWT for interface verification
2020-12-06
Go syntax variable
Sequence list and linked list - primary level
Youcans' opencv lesson - 10 Image restoration and reconstruction
2020-12-07
[DFS "want" or "don't"] seek subsets; Seeking combination
Key points of code neatness (III)
Use of pnpm package management tool
Requirements and business model innovation - Requirements 12 - process oriented modeling
$LastExitCode=0, but $?= False in PowerShell. Redirecting stderr to stdout gives NativeCommandError
Functions (arguments, formal parameters, bubbling)
根據變換矩陣進行圖像拼接