This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Delete neural inputs, layers, and outputs with sizes of zero


[net,pi,pl,po] = prune(net)


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


The same network with zero-sized subobjects removed


Indices of pruned inputs


Indices of pruned layers


Indices of pruned outputs


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);

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);
[Xs2,Xi2,Ai2,Ts2] = prunedata(net,pi,pl,po,Xs,Xi,Ai,Ts)
[sysName,netName] = gensim(net);

See Also


Introduced in R2010b

Was this topic helpful?