NetBidirectionalOperator

NetBidirectionalOperator[net]

represents a net that applies net to a sequence and to its reverse, concatenating both results into one output sequence.

NetBidirectionalOperator[{fnet,bnet}]

uses fnet on the normal input and bnet on the reversed input.

NetBidirectionalOperator[net,agg]

aggregates the two output sequences using the specified aggregation function.

Details and Options

  • In NetBidirectionalOperator[net], net should be a net that takes a sequence and produces a sequence.
  • Valid settings for agg include:
  • Catenatecatenate the forward and reversed outputs (default)
    Totaladd the forward and reversed outputs
    Meantake the mean of the forward and reversed outputs
  • NetBidirectionalOperator[net,Catenate] will concatenate each element of the forward and reversed outputs, rather than concatenating the sequences themselves.
  • If net produces a sequence of vectors of length n, NetBidirectionalOperator[net,Catenate] will produce a sequence of vectors of length 2n. For the aggregation functions Total and Mean, the vectors will be of length n.
  • For the reversed application of net, the input is first reversed, then net is applied normally, then the output is again reversed, before concatenation with the forward application of net.
  • NetBidirectionalOperator[net] creates two copies of net that are trained independently, and is equivalent to NetBidirectionalOperator[{net,net}].
  • NetExtract allows access to the forward and reverse nets via "ForwardNet" and "ReverseNet".
  • In NetBidirectionalOperator[net], net is often one of the recursive layers BasicRecurrentLayer, GatedRecurrentLayer or LongShortTermMemoryLayer.

Examples

open allclose all

Basic Examples  (3)

Create a bidirectional operator that contains two LSTM layers:

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

Apply the operator to an input:

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

Create a bidirectional operator using different nets for the forward and backward passes:

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

Apply the operator to an input:

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

Create a bidirectional operator with a specific aggregation function:

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

Apply the operator to an input:

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

Possible Issues  (1)

See Also

BasicRecurrentLayer  GatedRecurrentLayer  LongShortTermMemoryLayer  NetExtract  SequenceReverseLayer  CatenateLayer  AggregationLayer  NetFoldOperator  NetMapOperator

Introduced in 2018
(11.3)