compressNetworkUsingProjection
Syntax
Description
The compressNetworkUsingProjection
function reduces the
number of learnable parameters of layers by performing principal component analysis (PCA) of
the neuron activations using a data set representative of the training data and then projects
the learnable parameters into the subspace that maintains the highest variance in neuron
activations. In some cases, this operation is equivalent to replacing layers with networks
containing two or more layers with fewer learnable parameters.
Depending on the network, projection configuration, and code generation libraries used (including library-free code generation), forward passes of a projected deep neural network can be faster when you deploy the network to embedded hardware.
If you prune or quantize your network, then use compression using projection after pruning and before quantization.
compresses the netProjected
= compressNetworkUsingProjection(net
,mbq
)dlnetwork
object net
by replacing
layers with projected layers. The function compresses layers by performing principal
component analysis (PCA) of the neuron activations using the data in the
minibatchqueue
object mbq
and projects learnable
parameters into the subspace that maintains the highest variance in neuron activations.
This feature requires the Deep Learning Toolbox™ Model Quantization Library support package. This support package is a free add-on that you can download using
the Add-On Explorer. Alternatively, see Deep Learning Toolbox Model Quantization Library.
compresses the network using the data in the netProjected
= compressNetworkUsingProjection(net
,X1,...,XN
)dlarray
objects
X1,...,XN
, where N
is the number of network
inputs.
compresses the network using the netProjected
= compressNetworkUsingProjection(net
,npca
)neuronPCA
object
npca
. The PCA step can be computationally intensive. If you expect to
compress the same network multiple times (for example, when exploring different levels of
compression), then you can perform the PCA step up front using a neuronPCA
object.
[
also returns the structure netProjected
, info
] = compressNetworkUsingProjection(___)info
that contains information about the
projected layers, the reduction of learnable parameters, and the explained variance achieved
during compression.
[
specifies additional options using one or more name-value arguments.netProjected
, info
] = compressNetworkUsingProjection(___,Name=Value
)
Examples
Input Arguments
Output Arguments
Tips
Code generation does not support
ProjectedLayer
objects. To replaceProjectedLayer
objects in a neural network with the equivalent neural network that represents the projection, use theunpackProjectedLayers
function or set theUnpackProjectedLayers
option of thecompressNetworkUsingProjection
function to1
(true
).
Algorithms
References
[1] "Compressing Neural Networks Using Network Projection." Accessed July 20, 2023. https://www.mathworks.com/company/technical-articles/compressing-neural-networks-using-network-projection.html.
Extended Capabilities
Version History
Introduced in R2022bSee Also
dlnetwork
| minibatchqueue
| dlarray
| neuronPCA
| ProjectedLayer
| unpackProjectedLayers
| lstmProjectedLayer
| gruProjectedLayer