How to use removeLayers without layerNames (How to remove layers if the layers don't have names)?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Jalaj Gambhir
el 18 de Oct. de 2019
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 comentarios
Ver también
Categorías
Más información sobre Image Data Workflows en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!