How to use removeLayers without layerNames (How to remove layers if the layers don't have names)?
9 ビュー (過去 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!