当前位置:网站首页>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,</边栏推荐
- 【SemiDrive源码分析】【驱动BringUp】39 - Touch Panel 触摸屏调试
- OpenAtom XuperChain 开源双周报 |2022.7.11-2022.7.22
- ArgoCD 用户管理、RBAC 控制、脚本登录、App 同步
- Play with the one-stop plan of cann target detection and recognition [basic]
- Dynamic memory management
- Devops has been practiced for many years. What is the most painful thing?
- Cointegraph wrote: relying on the largest Dao usdd to become the most reliable stable currency
- Talk about practice, do solid work, and become practical: tour the digitalized land of China
- 【transformer】DeiT
- QT actual combat case (53) -- using qdrag to realize the drag puzzle function
猜你喜欢

【transformer】DeiT

机器人工程-教学品质-如何判定

GIS实战应用案例100篇(十七)-基于DEM制作三维地图

LeetCode46全排列(回溯入门)
![[computer explanation] NVIDIA released geforce RTX Super Series graphics cards, and the benefits of game players are coming!](/img/11/24f92b4362026ec2c01492d195560b.png)
[computer explanation] NVIDIA released geforce RTX Super Series graphics cards, and the benefits of game players are coming!

Insight into mobile application operation growth in 2022 white paper: the way to "break the situation" in the era of diminishing traffic dividends

Not only log collection, but also the installation, configuration and use of project monitoring tool sentry

Cointelegraph撰文:依托最大的DAO USDD成为最可靠的稳定币

Can communication test based on STM32: turn the globe

【C】 Program environment and pretreatment
随机推荐
mvc与三层结构终极区别
C control open source library: download of metroframework
Enable the free pan domain SSL certificate for kubesphere cluster and realize the automatic update and distribution of certificates
[knowledge summary] block and value range block
[OBS] DTS sent by video packet_ USEC calculation
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)
Cointelegraph撰文:依托最大的DAO USDD成为最可靠的稳定币
Purpose of SQL square brackets
分层强化学习综述:Hierarchical reinforcement learning: A comprehensive survey
QT actual combat case (53) -- using qdrag to realize the drag puzzle function
共模电感听过很多次,但是什么原理你们真的懂吗?
微生物健康,不要排斥人体内微生物
【每日一题】剑指 Offer II 115. 重建序列
【电脑讲解】NVIDIA发布GeForce RTX SUPER系列显卡,游戏玩家福利来了!
MySQL remote login
Cointegraph wrote: relying on the largest Dao usdd to become the most reliable stable currency
Wechat applet wx.request interface
常吃发酵馒头是否会伤害身体
OpenAtom XuperChain 开源双周报 |2022.7.11-2022.7.22
Argocd user management, RBAC control, script login, APP synchronization