Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

NetChain

NetChain[{layer1,layer2,}]
specifies a neural net in which the output of layeri is connected to the input of layeri+1.

NetChain["name1"layer1,"name2"layer2,]
specifies a net consisting of a chain of explicitly named layers.

DetailsDetails

  • The input of a NetChain is taken to be the input of the first layer.
  • The output of a NetChain is taken to be the output of the last layer.
  • All intermediary layers must have exactly one input and one output port.
  • NetChain supports the following special layer specifications:
  • nDotPlusLayer[n]
    Ramp,LogisticSigmoid,ElementwiseLayer[f]
  • Take and Drop work on the sequence of layers in NetChain objects, giving new NetChain objects.
  • The overall input and output tensor shapes for the chain can be specified using "Input"->shape and "Output"->shape options for NetChain.
  • Possible forms for shape include:
  • na vector of length n
    {n1,n2,}a tensor of dimensions n1×n2×
    NetEncoder[]an encoder (for input)
    NetDecoder[]a decoder (for output)

ExamplesExamplesopen allclose all

Basic Examples  (5)Basic Examples  (5)

Construct a chain consisting of one layer:

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

Apply the net to an input:

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

Construct a chain consisting of two layers:

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

Apply the net to an input:

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

Construct a chain consisting of two layers and specifying that the input is of size 2:

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

Initialize the net with random weights:

In[2]:=
Click for copyable input

Apply the net to an input vector:

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

Construct a chain with explicitly named layers:

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

Extract the second layer by name:

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

Construct a chain:

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

Construct a new network consisting of the first two layers:

In[2]:=
Click for copyable input
Out[2]=
Introduced in 2016
(11.0)