NetStateObject

NetStateObject[net]

creates an object derived from net that represents a neural net with additional stored state information that is updated when the net is applied to data.

NetStateObject[net,seed]

creates an object in which additional stored state information is initialized using seed.

Details

  • NetStateObject[][data] updates stored state information in the NetStateObject.
  • State information is associated with the state ports of recurrent net layers such as LongShortTermMemoryLayer.
  • NetStateObject will not store the state of layers whose state ports are initialized from other layers in a NetGraph.
  • When a seed is not provided, initial values for recurrent states will consist of arrays of zeros.
  • The current value of the stored states is given by NetExtract[NetStateObject[],"States"].

Examples

open allclose all

Basic Examples  (3)

Create a recurrent net:

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

Create a state object from the recurrent net:

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

Evaluate the state object on some data:

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

Due to the presence of the stored states, the behavior of the state object can change between evaluations, even on the same input:

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

Create a state object with a specified initial state:

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

Create a classifier that predicts the next element of a sequence:

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

Train the classifier on a set of input sequences:

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

Create a state object and use it to efficiently generate a maximum-likelihood sequence, starting from a single 1:

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

Applications  (1)

Properties & Relations  (3)

See Also

NetChain  NetGraph  BasicRecurrentLayer  GatedRecurrentLayer  LongShortTermMemoryLayer  NetFoldOperator

Tutorials

Introduced in 2018
(11.3)