当前位置:网站首页>Paddlepaddle 19 dynamically modify the last layer of the model
Paddlepaddle 19 dynamically modify the last layer of the model
2022-06-27 02:16:00 【Ten thousand miles' journey to】
During transfer learning , You usually need to modify the last layer of the model , Redefine as needed . however , Transfer learning needs comparative experiments in many models , And define the last one layer when , Need to know layer Of name, and layer The input data is shape, That is, we need to be right model Of layer Traversal .
1、 Traverse model
Through the following code, you can traverse model
import paddle
#print(' Built in model of propeller frame :', paddle.vision.models.__all__)
model=paddle.vision.resnet18()
layer_list=[(name,atom_layer) for name,atom_layer in model.named_sublayers()]
#print(model)
feature_layer_name,feature_layer=layer_list[-1]
feature_layer_shape=feature_layer.weight.shape
feature_layer_type=feature_layer.__class__
print("feature layer:",feature_layer_name,feature_layer_shape,feature_layer_type)The code execution output is as follows :
feature layer: fc [512, 1000] <class 'paddle.nn.layer.common.Linear'>
2、 Dynamically modify the last layer of the model
Dynamically modify the last layer of the model , Support semantic segmentation model and image classification model . But here's the thing , The last layer of the model must be layer object ( Such as resnet series ,densenet series ,mobilenet system
边栏推荐
- Memcached basics 13
- Oracle/PLSQL: Lpad Function
- P5.js death planet
- Oracle/PLSQL: Translate Function
- Oracle/PLSQL: Trim Function
- ConstraintLayout(约束布局)开发指南
- 达梦数据库的卸载
- 解决cherry pick提交报错问题
- Consumers pursue the iPhone because its cost performance exceeds that of domestic mobile phones
- Is the division of each capability domain of Dama, dcmm and other data management frameworks reasonable? Is there internal logic?
猜你喜欢

Parameter estimation -- Chapter 7 study report of probability theory and mathematical statistics (point estimation)

学习太极创客 — MQTT 第二章(二)ESP8266 QoS 应用

Canvas particles: mouse following JS effect

three.js多米诺骨牌js特效

使用命令行安装达梦数据库

CVPR2022 | PointDistiller:面向高效紧凑3D检测的结构化知识蒸馏

WiFi-IoT 鸿蒙开发套件样例开发

Flink learning 1: Introduction

Don't be brainwashed. This is the truth about the wages of 90% of Chinese people

P5.js death planet
随机推荐
three.js多米诺骨牌js特效
Oracle/PLSQL: Trim Function
memcached基础14
pytorch 23 hook的使用与介绍 及基于hook实现即插即用的DropBlock
我靠副业一个月挣了3W块:你看不起的行业,真的很挣钱!
Would rather go to 996 than stay at home! 24 years old, unemployed for 7 months, worse than work, no work
Oracle/PLSQL: Upper Function
Dameng database installation
memcached基础12
TechSmith Camtasia最新2022版详细功能讲解下载
pytorch 22 8种Dropout方法的简介 及 基于Dropout用4行代码快速实现DropBlock
Simply learn the entry-level concepts of googlecolab
Oracle/PLSQL: Ltrim Function
学习太极创客 — MQTT(七)MQTT 主题进阶
docker部署redis集群
Introduction to stm32
lottie. JS creative switch button animal head
p5.js死亡星球
1、项目准备与新建
为什么传递SPIF_SENDCHANGE标志SystemParametersInfo会挂起?