Borrar filtros
Borrar filtros

change outputlayer in layergraph object

4 visualizaciones (últimos 30 días)
Rubén
Rubén el 18 de Mayo de 2023
Comentada: Rubén el 24 de Mayo de 2023
Hello,
I have a layerGraph object and I need to remove the output layer because it is not relevant and it is not supported by Deep Learning HDL Toolbox.
I removed another layer and then make the corresponding connection but the output layer is different because I need to change the 'OutputNames' or set the out output layer in other way. However, 'OutputNames' property is read only.
I also tried to replace the last layer by the previous one and remove the previous layer but I get the same result
find in the following link the layerGraph object layers.mat
Is there any way to change the output layer in a layerGraph object?
Thank you in advance.

Respuesta aceptada

Matt J
Matt J el 18 de Mayo de 2023
For example,
lgraph=layerGraph(regressionLayer)
lgraph =
LayerGraph with properties: InputNames: {1×0 cell} OutputNames: {'regressionoutput'} Layers: [1×1 nnet.cnn.layer.RegressionOutputLayer] Connections: [0×2 table]
layers=lgraph.Layers;
layers(end).Name='newName';
lgraph=layerGraph(layers)
lgraph =
LayerGraph with properties: InputNames: {1×0 cell} OutputNames: {'newName'} Layers: [1×1 nnet.cnn.layer.RegressionOutputLayer] Connections: [0×2 table]
  8 comentarios
Matt J
Matt J el 21 de Mayo de 2023
Editada: Matt J el 21 de Mayo de 2023
It will definitely given an error because it has no input and output layers, but that is not the point. Your original question was how to change the output name property of an output layer within an existing layerGraph and my original answer demonstrated how to do that.
If the question is about making predictions in a network without using an output layer, you can do it by using dlnetwork instead of assembleNetwork.
cl=convolution2dLayer([3,3],1 ,'Padding','same','Weights',rand(3),'Bias',0);
net=dlnetwork(cl,networkDataLayout([8,8,1],'SSC'));
net.predict(dlarray(rand(8),'SSC'))
ans =
8(S) × 8(S) × 1(C) single dlarray 1.9330 1.6235 1.4864 1.6687 2.1314 1.7076 1.5632 1.1103 2.1311 2.7175 1.8709 3.1219 2.9320 2.4912 2.6637 1.8686 2.0587 2.2242 2.5526 2.5633 2.7993 2.7756 2.4032 1.2422 1.8285 2.6174 1.9562 2.4646 2.5606 2.4817 2.1627 1.1586 1.9782 2.2336 2.9013 2.7397 2.2003 2.0638 1.7779 1.1409 1.0009 2.6439 2.3893 3.0688 2.0361 2.4400 2.3526 1.9205 1.3489 2.1934 2.7162 2.8103 2.6220 2.7962 2.9462 2.1174 1.0200 1.3155 1.1040 1.8461 1.8275 1.5256 2.7954 2.0552
Rubén
Rubén el 24 de Mayo de 2023
I'm sorry but the original question was how to change the output layer itself. Maybe the misunderstanding comes because the 'OutputNames' property. Anyway, question is solved. Thank you

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by