Semantic Segmentation - How many layers to replace in transfer learning?

조회 수: 9 (최근 30일)
awezmm
awezmm 2019년 5월 1일
댓글: Guy Reading 2019년 9월 27일
Im doing semantic segmentation using Resnet-18 with Deeplab v3+ (https://www.mathworks.com/help/vision/examples/semantic-segmentation-using-deep-learning.html)
However, I want to retain on progressively harder tasks and want to use transfer learning. How many of the final layers should I be replacing? How do I figure out how many layers I have?
On the analyzeNetwork it says I have 101 but I am using Resnet - 18 which I thought had much less?
  댓글 수: 4
Tohru Kikawada
Tohru Kikawada 2019년 5월 11일
편집: Tohru Kikawada 2019년 5월 11일
Philip, you'll need to try this on R2019a since the example has been revised to use DeepLab v3 instead of SegNet in the latest vresion.
Guy Reading
Guy Reading 2019년 9월 27일
I've been doing a bit of digging on the resnet18() <-> DeepLab V3+ connection, in this link MATLAB writes:
"This example creates the Deeplab v3+ network with weights initialized from a pre-trained Resnet-18 network"
But then we might ask, "how do we use the weights trained on one network to be used in another? Won't they be meaningless relative to Deeplab?
Then this link writes:
"The latest implementation of DeepLab supports multiple network backbones, like MobileNetv2, Xception, ResNet-v1, PNASNET and Auto-DeepLab."
So I guess we can treat Deeplab V3+ as some form of extension of resnet18 and thus can use the weights.

댓글을 달려면 로그인하십시오.

답변 (2개)

Tohru Kikawada
Tohru Kikawada 2019년 5월 2일
Did you see helperDeeplabv3PlusResnet18.m which is attached to the example as a supporting file? The supporting function might be helpful to create your own transfer learning network.
  댓글 수: 4
awezmm
awezmm 2019년 5월 7일
I have already looked at the helperDeeplabv3PlusResnet18.m and said in my previous comment that is want not helpful...
Tohru Kikawada
Tohru Kikawada 2019년 5월 7일
Sorry for the confusion. Someone asked me where the file can be found.

댓글을 달려면 로그인하십시오.


Guy Reading
Guy Reading 2019년 9월 23일
Did you make any progress on this, @awezmm? I'm looking to do the same thing as you, with Resnet-18, too, and I got stuck at the same point as you so Googled & found your question here!
So far I've followed the (adapted for resnet) instructions of this tutorial:
So for resnet that'd be:
%% load a pre-trained CNN
pretrainedFolder = fullfile(tempdir,'pretrainedNetwork');
pretrainedNetwork = fullfile(pretrainedFolder,'deeplabv3plusResnet18CamVid.mat');
data = load(pretrainedNetwork);
net = data.net;
layers = net.Layers
This shows me all 101 layers for resnet. For me, personally, I'd like to classify 2 things (background or object) so I've edited the final layer to give me 2 things, but I'm pretty sure I need to do more layers and unsure which ones:
%% Modify the network to use 2 categories
layers(101) = pixelClassificationLayer; % note, in the example he uses classificationLayer as it's not semantic seg
& now I'm stuck! I'll comment r.e. letting you know any progress I've made... I'm going to look into the structure of resnet more, now, to get a better understanding of what I need to change and how...
  댓글 수: 5
Guy Reading
Guy Reading 2019년 9월 24일
Oh right! So I looked to replace the layers which are specific to the amount of classes we want to categorise into. So layers 97:101 refer to layers which have a dimension set to 11, which was the original amount of classes:
dagnet1.png
Which is why I chose those. But I'm not 100% certain! Have you got this working for you at all? / what's the intuition behind picking the last layer, only?
Guy Reading
Guy Reading 2019년 9월 26일
To all that are reading: the above method worked for me & I'm starting to get labelled images from my model. I'm still not sure about which layers to freeze, if there are any suggestions with that I'd be interested to hear!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by