当前位置:网站首页>OrderedDict构建函数模块的不常见写法
OrderedDict构建函数模块的不常见写法
2022-08-08 13:45:00 【fighterflyfly】
常见写法是直接把所有的子模块直接写在OrderedDict里面,即OrderedDict([(‘A’, XXX), (‘B’, YYY)] )不常见写法如下:
head = OrderedDict()
head.update({
"project_conv": ConvBNAct(head_input_c,
num_features,
kernel_size=1,
norm_layer=norm_layer)}) # 激活函数默认是SiLU
head.update({
"avgpool": nn.AdaptiveAvgPool2d(1)})
head.update({
"flatten": nn.Flatten()})
if dropout_rate > 0:
head.update({
"dropout": nn.Dropout(p=dropout_rate, inplace=True)})
head.update({
"classifier": nn.Linear(num_features, num_classes)})
self.head = nn.Sequential(head)
注意事项:nn.Sequential传入head时不用像传递list类型对象那样需要加一个*的标号
边栏推荐
- Three classic topics in C language: three-step flip method, Young's matrix, and tossing and dividing method
- poj2096 Collecting Bugs
- 良心到难以置信的网站推荐第7期丨全程干货
- textarea 禁止拖拽
- KD-SCFNet: More Accurate and Efficient Salient Object Detection Through Knowledge Distillation (ECCV2022)
- idea增加左右箭头
- 【低代码】1405- 浅谈低代码平台远程组件加载方案
- [Redis] Redis installation and use of client redis-cli (batch operation)
- leetcode 155. Min Stack最小栈(中等)
- sample function—R language
猜你喜欢
C language small project - complete code of minesweeper game (recursive expansion + selection mark)
代码随想录笔记_动态规划_322零钱兑换
自动当道,效率至上 | 快来解锁财务共享服务中心数字化秘籍
HackTheBox | Previse
Code Casual Recording Notes_Dynamic Programming_322 Change Exchange
[8月4日]剑指 Offer 52. 两个链表的第一个公共节点
LeetCode简单题之统计星号
PE文件-手工修改重定位表-WinHex-CFF Explorer
【Rust—LeetCode题解】1.两数之和
[界面开发]DevExpress WinForms流程图控件——XtraDiagrams组件入门指南
随机推荐
【JS高级】ES5标准规范之严格模式下的保护对象_09
mysql 查询一个字段为特定值,并且另一个字段的值出现两次的记录?
【Personal Summary】2022.8.7 Week End
PE文件-手工修改重定位表-WinHex-CFF Explorer
客户案例 | 提高银行信用卡客户贡献率
基于FPGA的FIR滤波器的实现(1)—采用fir1函数设计
leetcode 155. Min Stack最小栈(中等)
Photoshop插件-charIDToTypeID-PIStringTerminology.h-不同值的解释及参考-脚本开发-PS插件
php文件上传下载(存放文件二进制到数据库)
leetcode 155. Min Stack最小栈(中等)
【干货】交换机的接口类型完全实物了解
sample function—R language
(7) FlinkSQL kafka data written to the mysql way 2
优刻得“失速”:营收转降,定向增发股东浮亏超三成
HackTheBox | Horizontall
MapStruct入门使用
【软考 系统架构设计师】软件架构设计⑥ 软件产品线
TS+Hooks二次封装antd Modal,实现可拖拽
机器学习+深度学习笔记(持续更新~)
UnsatisfiedDependencyException: Error creating bean with name ‘