NetEvaluationMode

NetEvaluationMode

is an option that can be given when applying neural net functions to input data, specifying whether the net should use training-specific behavior.

Details

  • When a net is applied to an input, net[input,NetEvaluationMode->spec] specifies how layers such as DropoutLayer within the net should behave.
  • With the setting NetEvaluationMode->"Test", the normal behavior of layers like DropoutLayer will be used.
  • With the setting NetEvaluationMode->"Train", the training-specific behavior of layers like DropoutLayer will be used.
  • Recurrent layers such as LongShortTermMemoryLayer also have training-specific behavior via the "Dropout" option.
  • Training a net with NetTrain[net,] will automatically use training-specific behavior.

Examples

open allclose all

Basic Examples  (2)

Normally, training layers like DropoutLayer act like the identity. Create a dropout layer and apply it to an input:

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

Apply the dropout layer with its training behavior, in which roughly half of the vector components are set to zero and the other half are doubled:

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

Create an ImageAugmentationLayer that takes an image of size 128×128 and returns an image crop of size 64×64:

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

Apply the layer to an image, obtaining the center crop:

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

Apply the layer to an image, specifying that training behavior be used. A random crop will be made and the image will be reflected with the given probabilities:

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

Possible Issues  (1)

See Also

NetTrain  TargetDevice  DropoutLayer  BatchNormalizationLayer  ImageAugmentationLayer  BasicRecurrentLayer  GatedRecurrentLayer  LongShortTermMemoryLayer

Introduced in 2017
(11.1)