文章目录
- 1、简介
- 2、三者之间的区别
- 3、如何让nn.ModuleList 和nn.ModuleDict实现推理
- 3.1 方案1: 实现forward函数
- 3.2 方案2: 将nn.ModuleList 和nn.ModuleDict转换为nn.Sequential
- 4、nn.ModuleDict、nn.ModuleList 的区别
- 5、nn.ModuleList 、 nn.ModuleDict 与 Python list、Dict 的区别
在使用pytorch搭建网络的时候,经常会使用到
nn.Sequential
、
nn.ModuleDict
、
nn.ModuleList
这三个类, 这三个类都是继承自
nn.Module
类,本文将详细介绍这3个类的使用。