Main Content

unpackProjectedLayers

Unpack projected layers of neural network

Since R2023b

    Description

    netUnpacked = unpackProjectedLayers(net) replaces the layers of type ProjectedLayer with the corresponding network that represents the projection.

    Examples

    collapse all

    Load the pretrained network in dlnetProjectedJapaneseVowels.

    load dlnetProjectedJapaneseVowels

    View the network properties.

    net
    net = 
      dlnetwork with properties:
    
             Layers: [4x1 nnet.cnn.layer.Layer]
        Connections: [3x2 table]
         Learnables: [9x3 table]
              State: [2x3 table]
         InputNames: {'sequenceinput'}
        OutputNames: {'softmax'}
        Initialized: 1
    
      View summary with summary.
    
    

    View the network layers. The network has two projected layers.

    net.Layers
    ans = 
      4x1 Layer array with layers:
    
         1   'sequenceinput'   Sequence Input    Sequence input with 12 dimensions
         2   'lstm'            Projected Layer   Projected LSTM with 100 hidden units
         3   'fc'              Projected Layer   Projected fully connected layer with output size 9
         4   'softmax'         Softmax           softmax
    

    Unpack the projected layers.

    netUnpacked = unpackProjectedLayers(net)
    netUnpacked = 
      dlnetwork with properties:
    
             Layers: [5x1 nnet.cnn.layer.Layer]
        Connections: [4x2 table]
         Learnables: [9x3 table]
              State: [2x3 table]
         InputNames: {'sequenceinput'}
        OutputNames: {'softmax'}
        Initialized: 1
    
      View summary with summary.
    
    

    View the unpacked network layers. The unpacked network has a projected LSTM layer and two fully connected layers in place of the projected layers.

    netUnpacked.Layers
    ans = 
      5x1 Layer array with layers:
    
         1   'sequenceinput'   Sequence Input    Sequence input with 12 dimensions
         2   'lstm'            Projected LSTM    Projected LSTM layer with 100 hidden units, an output projector size of 7, and an input projector size of 8
         3   'fc_proj_in'      Fully Connected   4 fully connected layer
         4   'fc_proj_out'     Fully Connected   9 fully connected layer
         5   'softmax'         Softmax           softmax
    

    Input Arguments

    collapse all

    Neural network, specified as a dlnetwork object.

    Output Arguments

    collapse all

    Unpacked neural network, returned as a dlnetwork object.

    Tips

    • Code generation does not support ProjectedLayer objects. To replace ProjectedLayer objects in a neural network with the equivalent neural network that represents the projection, use the unpackProjectedLayers function or set the UnpackProjectedLayers option of the compressNetworkUsingProjection function to 1 (true).

    Version History

    Introduced in R2023b