How to return a DAGNetwork to an editable state in deepNetworkDesigner?

10 次查看(过去 30 天)
I started with a layer graph lgraph and opened it in a deepNetworkDesigner,
deepNetworkDesigner( lgraph )
The properties of the input (and other) layers are editable at this point,
After training however, I obtain net, a DAGNetwork object, and I find that it cannot be edited. Various properties, like the Normalization, are disabled,
deepNetworkDesigner( net )
My question is whether there is a way to recover, from the trained net object, the original LayerGraph in a form that is editable in deepNetworkDesigner.

采纳的回答

Shubh
Shubh 2024-1-25
Hi Matt,
Yes, you can convert a trained DAGNetwork object back into an editable LayerGraph object in MATLAB. The DAGNetwork object, obtained after training your network, contains the architecture and the trained weights, but as you've observed, it's not directly editable in the deepNetworkDesigner.
To convert the DAGNetwork back into an editable LayerGraph, you can use the layerGraph function provided by MATLAB. This function extracts the layer architecture (without the trained weights) from the DAGNetwork object. Here's how you can do it:
  1. Extract the layer architecture from the DAGNetwork object using layerGraph.
  2. Open the extracted layer graph in deepNetworkDesigner.
Here is the complete code for this process:
% Assuming 'net' is your trained DAGNetwork object
% Extract the layer architecture from the trained network
lgraph = layerGraph(net);
% Open the extracted layer graph in the Deep Network Designer
deepNetworkDesigner(lgraph);
This code will open the Deep Network Designer with the architecture of your trained network, where you can edit the properties of the input and other layers. Note that the trained weights are not included in the lgraph, so any changes you make and subsequent retraining will start from the beginning, unless you explicitly initialize the layers with the weights from the trained network.
Hope this helps!
  3 个评论
Shubh
Shubh 2024-1-27
Hi Matt,
From the given screenshot, I can see some properties faded out. There must be an option called "Unlock Layer" in the bottom right of this dialog box. Can you confirm ?
This will enable the editing for these properties and well, but will delete all the layer's learnable parameters. This is due to the constraints imposed by the pre-trained weights. For example, changing the filter size or the number of filters in a convolutional layer would invalidate the learned weights for that layer, hence these parameters are locked.
If you need to modify these non-editable parameters, one other approach is to manually reconstruct the layer graph and reinitialize the layers where changes are required. Here's a process to do this:
  1. Extract the layer architecture and properties from the 'DAGNetwork'.
  2. Manually create a new 'LayerGraph' with the desired modifications.
  3. If needed, transfer the weights from the original network to the new one for layers that remain unchanged.
Let me know if the above pointers are of help!
Matt J
Matt J 2024-1-29
Hi Shubh,
You seem to be real, non-AI !
There must be an option called "Unlock Layer" in the bottom right of this dialog box. Can you confirm ?
I do see that in R2023b, though not in R2021b. In fact, I even see a button on the master toolbar to unlock all layers! I guess that does answer my question, although it would be nice to find a programmatic way to do this.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Custom Training Loops 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by