dag2dlnetwork - Convert SeriesNetwork and DAGNetwork to
dlnetwork - MATLAB ([original](https://in.mathworks.com/help/deeplearning/ref/dag2dlnetwork.html)) ([raw](?raw))
Main Content
Convert SeriesNetwork
and DAGNetwork
todlnetwork
Since R2024a
Syntax
Description
[dlnet](#mw%5F8c2e8451-c001-4efa-8a0c-de90b4019c26) = dag2dlnetwork([net](#mw%5Ff1e204a4-5f30-41d9-bd17-853941f5dbd3))
converts the specified SeriesNetwork
or DAGNetwork
object to a dlnetwork object.
Examples
Load a trained SeriesNetwork
object into the workspace and inspect it.
net = SeriesNetwork with properties:
Layers: [15×1 nnet.cnn.layer.Layer]
InputNames: {'imageinput'}
OutputNames: {'classoutput'}
Convert the network to a dlnetwork
object.
dlnet = dag2dlnetwork(net)
dlnet = dlnetwork with properties:
Layers: [14×1 nnet.cnn.layer.Layer]
Connections: [13×2 table]
Learnables: [14×3 table]
State: [6×3 table]
InputNames: {'imageinput'}
OutputNames: {'softmax'}
Initialized: 1
View summary with summary.
Input Arguments
Input network, specified as a SeriesNetwork
orDAGNetwork
object.
Algorithms
The dag2dlnetwork
function applies these adjustments to the input network to make it compatible with dlnetwork functionality:
- Remove the output layers — To specify the loss function when you train a neural network, use the trainnet function.
- Replace fully connected layers with convolution layers — For neural networks that require fully connected layers to output data with singleton spatial dimensions, the
dag2dlnetwork
function replaces the fully connected layer with the equivalent convolutional layer. Otherwise, thedag2dlnetwork
function does not replace the layer. In the outputdlnetwork
object, the fully connected layer outputs data without spatial dimensions. - For networks that output singleton spatial dimensions, include a flatten layer — For neural networks that output data with singleton spatial dimensions (for example, a SqueezeNet neural network), the
dag2dlnetwork
function adds a flatten layer at the end of network that removes the singleton spatial dimensions. - Return an uninitialized network when they contains unsupported layers — If the network contains layers that
dlnetwork
objects do not support, then the function returns an uninitializeddlnetwork
object. To remove or replace unsupported layers in adlnetwork
object, use the removeLayers and replaceLayer functions, respectively.
Version History
Introduced in R2024a