当前位置:网站首页>paddlepaddle 34 调整模型的layer结构与forward流程(实现layer的增删改与forward的修改)
paddlepaddle 34 调整模型的layer结构与forward流程(实现layer的增删改与forward的修改)
2022-07-25 07:04:00 【万里鹏程转瞬至】
通常来说调整模型的layer结构与forward流程需要修改模型的定义代码,这会污浊了原始的模型定义代码。且,在源码层次进行模型结构修改后,会导致模型无法加载适应以前的预训练参数。为此博主实现了在不污浊模型定义代码的前提下,仅对model对象进行属性修改,实现了模型layer结构与forward流程的调整。本来博主在pytorch下是已经实现了该工作(实现链接),但是在应用到paddle下出现了水土不服,因此针对paddle框架在此进行该工作。
本博文主要设置layer的新增、修改与删除,forward流程的修改。其中,layer的修改其实已经在本栏目的第29章实现了。这里在此简述一下。
1、layer的修改与删除
layer的修改与删除在paddle model中其实就是一回事,修改是指将layer替换为新的layer,删除是指将layer替换为空layer(nn.Sequential()对象)。其核心就是实现layer的替换,其替换代码如下所示:
import paddle
def _set_module(model,</边栏推荐
- YOLOv7模型推理和训练自己的数据集
- Recycleview realizes horizontal sliding of overlapping items
- [semidrive source code analysis] [drive bringup] 39 - touch panel touch screen debugging
- Purpose of SQL square brackets
- Upload and download multiple files using web APIs
- labelme标注不同物体显示不同颜色以及批量转换
- Default value of dart variable
- [knowledge summary] block and value range block
- 大话西游服务端启动注意事项
- Observer mode
猜你喜欢

RecycleView实现item重叠水平滑动

Tp5.1 foreach adds a new field in the controller record, and there is no need to write all the other fields again without changing them (not operating in the template) (paging)

Devops has been practiced for many years. What is the most painful thing?
![[Yugong series] July 2022 go teaching course 015 assignment operators and relational operators of operators](/img/37/4a892b96bec8cfa7efe38046c5dfc9.png)
[Yugong series] July 2022 go teaching course 015 assignment operators and relational operators of operators

Robot engineering - teaching quality - how to judge

File operation-

YOLOv7模型推理和训练自己的数据集

Leetcode46 Full Permutation (Introduction to backtracking)

【terminal】x86 Native Tools Command Prompt for VS 2017
![[yolov5 practice 3] traffic sign recognition system based on yolov5 - model training](/img/2f/1d2938dafa17c602c9aaf640be9bf1.png)
[yolov5 practice 3] traffic sign recognition system based on yolov5 - model training
随机推荐
vulnhub CyberSploit: 1
Argocd user management, RBAC control, script login, APP synchronization
Yolov7 model reasoning and training its own data set
[Yugong series] July 2022 go teaching course 015 assignment operators and relational operators of operators
探讨影响自动化测试成败的重要因素
Vscode saves setting configuration parameters to the difference between users and workspaces
杜教筛
Dynamic memory management
Can interface debugging still play like this?
[cann training camp] play with the one-stop plan of cann target detection and recognition - learning notes 1 (initial experience)
The income of bank financial management is getting lower and lower. Now which financial products have high income?
Standard C language 6
[yolov5 practice 3] traffic sign recognition system based on yolov5 - model training
代码中的软件工程:正则表达式十步通关
The relationship between Informatics, mathematics and Mathematical Olympiad (July 19, 2022) C
C # --metroframework framework calls the metromodernui library and uses it in the toolbar
What are the hazards of insufficient sleep?
【terminal】x86 Native Tools Command Prompt for VS 2017
Labelme labels different objects, displays different colors and batch conversion
章鱼网络 Community Call #1|开启 Octopus DAO 构建