Change parameters of network from Deep Network Designer

20 ビュー (過去 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 件のコメント
Matt K.
Matt K. 2022 年 9 月 6 日
Thanks for the reply. This makes sense.

サインインしてコメントする。

その他の回答 (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 Center および File ExchangeImage Data Workflows についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by