How to change last layer of Resnet50 in Deep network designer App

8 次查看(过去 30 天)
Hello, I hope you are doing well. I want to change the last layer of Resnet50 with my 4 classes, Currently I am using Deep network Desiginer app
How can i do that in MATALAB

回答(1 个)

Milan Bansal
Milan Bansal 2024-9-11,17:30
Hi Med Future
By default Resnet50 is used for classification of 1000 classes. If you wish to modify the model such that it can be used to classify your four classes, replace the last fully connected layer "fc1000" which has an output size of 1000 with a new fully connect layer with output size 4.
Please refer to the following steps to implement this.
1.) Load the resnet50 model in workspace.
net = resnet50;
2.) Open Deep Network Designer Application and load the net from workspace.
3.) Find the layer with the name "fc1000" which should be the last 3rd layer of the model.
4.) Delete "fc1000" and replace it with a new fully connected layer. Set the outputSize of new layer as 4. Save the model into workspace.
Refer to the following documentation links to learn more:
In R2024a resnetNetwork function is introduced which take numClasses as one of the inputs and return the desired model. Here is documentation: https://www.mathworks.com/help/releases/R2024a/deeplearning/ref/resnetnetwork.html
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by