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

6 views (last 30 days)
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.

Accepted Answer

Shubh
Shubh on 25 Jan 2024
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 Comments
Shubh
Shubh on 27 Jan 2024
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 on 29 Jan 2024
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.

Sign in to comment.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!