unpackProjectedLayers - Unpack projected layers of neural network - MATLAB (original) (raw)
Main Content
Unpack projected layers of neural network
Since R2023b
Syntax
Description
[netUnpacked](#mw%5Fba3d4854-6268-432e-8474-df9c2875eb52) = unpackProjectedLayers([net](#mw%5F54a666d6-eb49-4791-9587-0c37b8c2464e%5Fsep%5Fmw%5F3ffb42b3-6af7-4c22-82b3-4fb0f6a399f2))
replaces the layers of type ProjectedLayer
with the corresponding network that represents the projection.
Examples
Unpack Projected Layers
Load the pretrained network in dlnetProjectedJapaneseVowels
.
load dlnetProjectedJapaneseVowels
View the network properties.
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.
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.
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
net
— Neural network
dlnetwork
object
Neural network, specified as a dlnetwork object.
Output Arguments
netUnpacked
— Unpacked neural network
dlnetwork
object
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 theUnpackProjectedLayers
option of thecompressNetworkUsingProjection
function to1
(true
).
Version History
Introduced in R2023b