Change parameters of network from Deep Network Designer
14 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
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
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);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!