How to use removeLayers without layerNames (How to remove layers if the layers don't have names)?
조회 수: 6 (최근 30일)
이전 댓글 표시
When I am using transfer learning with ResNet50 I am removing the last 3 layers of ResNet as follows:
net = resnet50;
lgraph = layerGraph(net);
lgraph = removeLayers(lgraph, {'fc1000','fc1000_softmax','ClassificationLayer_fc1000'});
However, syntax for removeLayers is
newlgraph = removeLayers(lgraph,layerNames)
Right now I am trying to use transfer learning with MobileNetv2, but the last 3 layers are not named and doesn't have layerNames specified after checking the layers with the following code:
net = mobilenetv2;
lgraph = layerGraph(net);
alllayers = lgraph.Layers
How can I remove the last 3 layers or n number of layers of MobileNetv2 in order to use transfer learning with my own classifier?
댓글 수: 2
답변 (1개)
Jalaj Gambhir
2019년 10월 18일
Hi,
I cannot reproduce the issue at my end. The same snippet of code that you mentioned, gives the layer details including the Layer Names of all 155 Layers of MobileNetv2. And, I am able to remove layers with the procedure you mentioned with resnet50.
Another method of creating a new layer graph with the required layer is to use addLayers as mentioned below:
newlgraph = layerGraph;
net = mobilenetv2;
lgraph = layerGraph(net);
alllayers = lgraph.Layers;
newlgraph = addLayers(newlgraph, alllayers(1:end-3))
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!