NetTake

NetTake[net,end]

takes only those layers up to end in a NetChain or NetGraph.

NetTake[net,{start,end}]

takes only those layers between start and end in a NetChain or NetGraph.

Details

  • The following forms can be used for start and end:
  • n,"layer"a specified layer
    NetPort[{layer,"port"}]the specified input or output port of a layer
    NetPort["port"]an input or output port of the entire graph
    Allall of the inputs or outputs of the graph
    {spec1,spec2,}the union of the speci
  • NetTake[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)

Take the first two layers of a chain:

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

Take layers 2 through 4:

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

Create a net with two outputs:

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

Use NetTake to obtain a subnet that computes only one of the outputs:

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

Scope  (1)

See Also

NetDrop  Take  NetExtract  NetFlatten  NetReplace  NetReplacePart  NetRename  NetDelete  NetInsert  NetAppend  NetPrepend  NetChain  NetGraph

Tutorials

Introduced in 2018
(11.3)