prune
Delete neural inputs, layers, and outputs with sizes of zero
Syntax
[net,pi,pl,po] = prune(net)
Description
This function removes zero-sized inputs, layers, and outputs from a network. This leaves a network which may have fewer inputs and outputs, but which implements the same operations, as zero-sized inputs and outputs do not convey any information.
One use for this simplification is to prepare a network with zero sized subobjects for Simulink®, where zero sized signals are not supported.
The companion function prunedata
can prune data to remain consistent with
the transformed network.
[net,pi,pl,po] = prune(net)
takes a neural network and returns
net | The same network with zero-sized subobjects removed |
pi | Indices of pruned inputs |
pl | Indices of pruned layers |
po | Indices of pruned outputs |
Examples
Here a NARX dynamic network is created which has one external input and a second input which feeds back from the output.
net = narxnet(20); view(net)
The network is then trained on a single random time-series problem with 50 timesteps. The external input happens to have no elements.
X = nndata(0,1,50); T = nndata(1,1,50); [Xs,Xi,Ai,Ts] = preparets(net,X,{},T); net = train(net,Xs,Ts);
The network and data are then pruned before generating a Simulink diagram and initializing its input and layer states.
[net2,pi,pl,po] = prune(net); view(net2) [Xs2,Xi2,Ai2,Ts2] = prunedata(net,pi,pl,po,Xs,Xi,Ai,Ts); [sysName,netName] = gensim(net2); setsiminit(sysName,netName,net2,Xi2,Ai2);
Version History
Introduced in R2010b