NetDrop

NetDrop[chain,n]

removes the first n layers from a NetChain.

NetDrop[chain,-n]

removes the last n layers from a NetChain.

NetDrop[chain,{start,end}]

drops the layers between start and end in a NetChain.

Details

  • For NetDrop[chain,{start,end}], the start and end can be given as an integer n, which specifies the n^(th) layer, or "name", which specifies a named layer in a NetChain that was constructed using <|"name"->layer,|>.
  • When removing layers from the interior of a NetChain, the input shape of the first removed layer and the output shape of the last removed layer must match.
  • Any NetEncoder or NetDecoder that is present on the chain will be preserved, if possible.
  • NetDrop[net,spec,"port1"->spec1,] can be used to give types for the input and/or output of the resulting NetChain or NetGraph, using the normal type specifications those functions allow. The new port specifications will replace any existing NetEncoder, NetDecoder or type.

Examples

open allclose all

Basic Examples  (2)

Construct a chain consisting of four layers:

In[1]:=
Click for copyable input
Out[1]=

Drop layers from the beginning of the chain:

In[2]:=
Click for copyable input
Out[2]=

Drop layers from the end of the chain:

In[3]:=
Click for copyable input
Out[3]=

Drop layers from the middle of a chain:

In[4]:=
Click for copyable input
Out[4]=

Drop layers from the middle of a chain, referring to them by name:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Scope  (1)

Possible Issues  (1)

See Also

NetTake  Drop  NetExtract  NetFlatten  NetReplace  NetReplacePart  NetRename  NetDelete  NetInsert  NetAppend  NetPrepend  NetChain

Tutorials

Introduced in 2018
(11.3)