({{, (RefLink[NetBidirectionalOperator, paclet:ref/NetBidirectionalOperator])[net]
represents a net that applies net to a sequence and to its reverse, concatenating both results into one output sequence.}, {, (RefLink[NetBidirectionalOperator, paclet:ref/NetBidirectionalOperator])[{fnet,bnet}]
uses fnet on the normal input and bnet on the reversed input.}, {, (RefLink[NetBidirectionalOperator, paclet:ref/NetBidirectionalOperator])[net,agg]
aggregates the two output sequences using the specified aggregation function.}})

OpenersNotesSection(Spacer1)Details and Options

In (RefLink[NetBidirectionalOperator, paclet:ref/NetBidirectionalOperator])[net], net should be a net that takes a sequence and produces a sequence.

Valid settings for agg include:

(RefLink[NetBidirectionalOperator, paclet:ref/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, (RefLink[NetBidirectionalOperator, paclet:ref/NetBidirectionalOperator])[net,Catenate] will produce a sequence of vectors of length 2n. For the aggregation functions (RefLink[Total, paclet:ref/Total]) and (RefLink[Mean, paclet:ref/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.

(RefLink[NetBidirectionalOperator, paclet:ref/NetBidirectionalOperator])[net] creates two copies of net that are trained independently, and is equivalent to (RefLink[NetBidirectionalOperator, paclet:ref/NetBidirectionalOperator])[{net,net}].

(RefLink[NetExtract, paclet:ref/NetExtract]) allows access to the forward and reverse nets via "ForwardNet" and "ReverseNet".

In (RefLink[NetBidirectionalOperator, paclet:ref/NetBidirectionalOperator])[net], net is often one of the recursive layers (RefLink[BasicRecurrentLayer, paclet:ref/BasicRecurrentLayer]), (RefLink[GatedRecurrentLayer, paclet:ref/GatedRecurrentLayer]) or (RefLink[LongShortTermMemoryLayer, paclet:ref/LongShortTermMemoryLayer]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (4)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Create a bidirectional operator that contains two LSTM layers:

net=LongShortTermMemoryLayer[3,"Input"->{"Varying",2}];
bidir=NetInitialize@NetBidirectionalOperator[net]

Apply the operator to an input:

bidir[{{1,2},{0,1},{0,2}}]

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

forward=BasicRecurrentLayer[2,"Input"->{"Varying",2}];
backward=BasicRecurrentLayer[4,"Input"->{"Varying",2}];
bidir=NetInitialize@NetBidirectionalOperator[{forward,backward}]

Apply the operator to an input:

bidir[{{1,2},{0,1},{0,2}}]

Create a bidirectional operator with a specific aggregation function:

net=LongShortTermMemoryLayer[3,"Input"->{"Varying",2}];
bidir=NetInitialize@NetBidirectionalOperator[net,Total]

Apply the operator to an input:

bidir[{{1,2},{0,1},{0,2}}]

OpenersExampleSection2(Spacer1)Possible Issues  (1)

For aggregation functions (RefLink[Total, paclet:ref/Total]) and (RefLink[Mean, paclet:ref/Mean]), the forward and backward nets must produce sequences of arrays of the same size:

forward=BasicRecurrentLayer[2,"Input"->{"Varying",2}];
backward=BasicRecurrentLayer[4,"Input"->{"Varying",2}];
NetBidirectionalOperator[{forward,backward}]

NetBidirectionalOperator[{forward,backward},Total]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[BasicRecurrentLayer, paclet:ref/BasicRecurrentLayer])  ▪  (RefLink[GatedRecurrentLayer, paclet:ref/GatedRecurrentLayer])  ▪  (RefLink[LongShortTermMemoryLayer, paclet:ref/LongShortTermMemoryLayer])  ▪  (RefLink[NetExtract, paclet:ref/NetExtract])  ▪  (RefLink[SequenceReverseLayer, paclet:ref/SequenceReverseLayer])  ▪  (RefLink[CatenateLayer, paclet:ref/CatenateLayer])  ▪  (RefLink[AggregationLayer, paclet:ref/AggregationLayer])  ▪  (RefLink[NetFoldOperator, paclet:ref/NetFoldOperator])  ▪  (RefLink[NetMapOperator, paclet:ref/NetMapOperator])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Neural Networks, paclet:guide/NeuralNetworks])}})}})