当前位置:网站首页>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
边栏推荐
- Dameng database installation
- Memcached basics 14
- Oracle/PLSQL: From_Tz function
- DAMA、DCMM等数据管理框架各个能力域的划分是否合理?有内在逻辑吗?
- Learn from Taiji Maker - mqtt Chapter 2 (I) QoS service quality level
- Oracle/PLSQL: To_ Clob Function
- h5液体动画js特效代码
- Oracle/PLSQL: Soundex Function
- Flink学习3:数据处理模式(流批处理)
- Flink learning 3: data processing mode (stream batch)
猜你喜欢

Installing the Damon database using the command line

Google began to roll itself, AI architecture pathways was blessed, and 20billion generation models were launched

three.js多米诺骨牌js特效

Flink learning 2: application scenarios

Introduction to stm32

Would rather go to 996 than stay at home! 24 years old, unemployed for 7 months, worse than work, no work

lottie.js创意开关按钮动物头像

C语言--职工信息管理系统设计

Learning Tai Chi Maker - mqtt (VII) advanced mqtt theme

Flink學習2:應用場景
随机推荐
mmdetection 用yolox训练自己的coco数据集
“所有专业都在劝退”,对大学生最友好的竟然是它?
参数估计——《概率论及其数理统计》第七章学习报告(点估计)
Memcached basics 13
pytorch 22 8种Dropout方法的简介 及 基于Dropout用4行代码快速实现DropBlock
按键控制LED状态翻转
Oracle/PLSQL: Translate Function
Learn from Taiji Maker - mqtt Chapter 2 (I) QoS service quality level
Memcached foundations 12
Don't be brainwashed. This is the truth about the wages of 90% of Chinese people
Memcached basics 14
Installing the Damon database using the command line
docker部署redis集群
How does the C # TCP server limit the number of connections to the same IP?
谷歌开始卷自己,AI架构Pathways加持,推出200亿生成模型
解决cherry pick提交报错问题
学习太极创客 — MQTT 第二章(三)保留消息
Oracle/PLSQL: Trim Function
Flink learning 1: Introduction
Memcached basics 11