Main Content

dag2dlnetwork

Convert SeriesNetwork and DAGNetwork to dlnetwork

Since R2024a

    Description

    dlnet = dag2dlnetwork(net) converts the specified SeriesNetwork or DAGNetwork object to a dlnetwork object.

    example

    Examples

    collapse all

    Load a trained SeriesNetwork object into the workspace and inspect it.

    load digitsSeriesNet
    net
    net = 
      SeriesNetwork with properties:
    
             Layers: [15x1 nnet.cnn.layer.Layer]
         InputNames: {'imageinput'}
        OutputNames: {'classoutput'}
    
    

    Convert the network to a dlnetwork object.

    dlnet = dag2dlnetwork(net)
    dlnet = 
      dlnetwork with properties:
    
             Layers: [14x1 nnet.cnn.layer.Layer]
        Connections: [13x2 table]
         Learnables: [14x3 table]
              State: [6x3 table]
         InputNames: {'imageinput'}
        OutputNames: {'softmax'}
        Initialized: 1
    
      View summary with summary.
    
    

    Input Arguments

    collapse all

    Input network, specified as a SeriesNetwork or DAGNetwork object.

    Output Arguments

    collapse all

    Converted network, returned as a dlnetwork object.

    Algorithms

    collapse all

    dlnetwork Conversion

    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, the dag2dlnetwork function does not replace the layer. In the output dlnetwork 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 uninitialized dlnetwork object. To remove or replace unsupported layers in a dlnetwork object, use the removeLayers and replaceLayer functions, respectively.

    Version History

    Introduced in R2024a