# NetBidirectionalOperator

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 , net should be a net that takes a sequence and produces a sequence.
• Valid settings for agg include:
•  Catenate catenate the forward and reversed outputs (default) Total add the forward and reversed outputs Mean take 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.
• 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 , 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]:=
 Out[1]=

Apply the operator to an input:

 In[2]:=
 Out[2]=

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

 In[1]:=
 Out[1]=

Apply the operator to an input:

 In[2]:=
 Out[2]=

Create a bidirectional operator with a specific aggregation function:

 In[1]:=
 Out[1]=

Apply the operator to an input:

 In[2]:=
 Out[2]=