Change parameters of network from Deep Network Designer

조회 수: 18 (최근 30일)
Matt K.
Matt K. 2022년 9월 2일
댓글: Matt K. 2022년 9월 6일
Hi,
I haven't been able to find the answer to this question in the boards, but perhaps I'm using the wrong terminology.
I designed a 2D Unet using the Deep Network Designer so that I could get a better understanding of how everything links together and the different parameters of each layer. I did the "generate code" option so that I can easily run the .mlx file and get my network.
Now I want a different Unet that has the same structure, but a different number of filters in the final convolution layer. I can manually edit the network using the Deep Network Designer, but I'd rather do this programmatically, however I get a read only error:
This is the final convolution layer from the Deep Network Designer
>> lgraph.Layers(76)
ans =
Convolution2DLayer with properties:
Name: 'conv_19'
Hyperparameters
FilterSize: [3 3]
NumChannels: 'auto'
NumFilters: 2
Stride: [1 1]
DilationFactor: [1 1]
PaddingMode: 'same'
PaddingSize: []
PaddingValue: 0
Learnable Parameters
Weights: []
Bias: []
This is the error that I get when changing the NumFilters
>> lgraph.Layers(76).NumFilters=6
Unable to set the 'NumFilters' property of class
'Convolution2DLayer' because it is read-only.
Can anyone offer any suggestions? I feel like I'm missing a simple step.
Thank you!

채택된 답변

Yash Srivastava
Yash Srivastava 2022년 9월 6일
It is my understanding that you are trying to change the properties of a convolution layer in a neural network after exporting it from Deep Network Designer.
The properties of layer cannot be changed once they are created. As a work-around to this you can create a new convolution layer with the desired number of filters and use the “replaceLayer” function to add it to the graph.
Please refer to the https://in.mathworks.com/help/deeplearning/ref/layergraph.replacelayer.html documentation for information on how to use “replaceLayer” function.

추가 답변 (1개)

Sina Alizad
Sina Alizad 2022년 9월 6일
use this trick
1-save to a temp net
2-change props in the tmp net
3-load back and assemble the network
1)
tmp_net = lgraph.saveobj;
2)
tmp_net.Layers(2,1).Weights = w1;
tmp_net.Layers(2,1).Bias = b1;
3)
convnet = lgraph.loadobj(tmp_net);
convnet=assembleNetwork(convnet);

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by