How to quickly find the layer by its name in deep learning?

조회 수: 13 (최근 30일)
cui,xingxing
cui,xingxing 2020년 4월 23일
댓글: cui,xingxing 2020년 6월 20일
In the deep learning toolbox, I cannot easily manipulate a specific layer. For example, I know the name of a layer. How can I quickly find it in the layer array?
layers = [convolution2dLayer(3,3,'name','aa');
reluLayer('name','bb');
convolution2dLayer(3,3,'name','cc')]
For example, if I want to find a convolutional layer named "cc", can I only find one by one in a for loop? When there are many layers(There are dozens of layers), this method is very inefficient!
for i = 1:length(layers)
if strcmp(layers(i).Name,'cc')
myfindLayer = layers(i);
break;
end
end
If only
myfindLayer = layers ('cc')
can be operated like this! I hope the official will consider such a method, easy to operate!

채택된 답변

Ayush Laddha
Ayush Laddha 2020년 6월 18일
I understand that you wish to search a layer based upon its name and not using its index. You can make use of the Name property of a layer. Let’s consider the layer array you mentioned in the question and you want to find the layer with name ‘cc’.
You can use –
layers({layers.Name} == "cc")
or
layers(strcmp({layers.Name}, 'cc'))
Don’t forget to put double-quotes (“ “) in case you are comparing using ‘==’ operator or else use string(‘cc’).
You can also refer to the below documentation -

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by