How Can I change the Layer Names of my Network So I can Import It?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ian Dover
le 23 Mar 2020
Réponse apportée : Sai Bhargav Avula
le 26 Mar 2020
I'm trying to import a network that I trained myself using this code. This code is run twice. It fails on the second attempt:
classes = ["Parasitized" "Uninfected"];
malaria_alexnet = 'C:\<directory>\malaria_alexnet_step2_accuracy_0.95952.onnx';
malaria_alexnet = importONNXNetwork(malaria_alexnet,'OutputLayerType','classification','Classes',classes);
lgraph = layerGraph(malaria_alexnet.Layers);
malaria_alexnet = trainNetwork(augimdsTrain,lgraph,options);
The reason that I use **lgraph = layerGraph(malaria_alexnet.Layers);** is because I don't want to drop my weights.
However, when I import this network the second time, I get this error:
Error using nnet.internal.cnn.util.validateLayersForLayerGraph>iAssertUniqueAndNonEmptyLayerNames (line 56)
Layer names in layer array must be different from the names of layers in layer graph.
Error in nnet.internal.cnn.util.validateLayersForLayerGraph (line 33)
iAssertUniqueAndNonEmptyLayerNames(larray, existingLayers);
Error in nnet.cnn.LayerGraph>iValidateLayers (line 551)
larray = nnet.internal.cnn.util.validateLayersForLayerGraph(larray, existingLayers);
Error in nnet.cnn.LayerGraph/addLayers (line 190)
larray = iValidateLayers(larray, existingLayers);
Error in nnet.internal.cnn.onnx.translateONNX>makeConnections (line 301)
NNTLayerGraph = addLayers(NNTLayerGraph, NNTLayers{L});
Error in nnet.internal.cnn.onnx.translateONNX (line 131)
NNTLayerGraphOrArray = makeConnections(NNTLayers, thisGraph, initializerNames);
Error in nnet.internal.cnn.onnx.importONNXNetwork (line 8)
LayersOrGraph = nnet.internal.cnn.onnx.translateONNX(modelProto, OutputLayerType, UserImageInputSize, true);
Error in importONNXNetwork (line 52)
Network = nnet.internal.cnn.onnx.importONNXNetwork(modelfile, varargin{:});
Error in sgd_with_restarts_imported_network (line 17)
malaria_alexnet = importONNXNetwork(malaria_alexnet,'OutputLayerType','classification','Classes',classes);
How can I import my .onnx file or change the layer names to something different than what is found in layer graph?
0 commentaires
Réponse acceptée
Sai Bhargav Avula
le 26 Mar 2020
Hi,
For the above mentioned purpose you can try using the importONNXLayers. Set the 'ImportWeights' name-value argument to true to retain the weights. This way you can play around with the layers, instead of importing it twice.
Hope this helps!
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Image Data Workflows dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!