LEVIATHAN SYSTEMS

Buyer's Guide

A Bidirectional Sequence Summary Needs Both Traversal Endpoints

Technical contentPublished Updated

For a requirement calling for both directional final hidden states, select the forward state after the last original input and the reverse state after the first original input. Selecting both features at the last original position returns a different object. In the stipulated BI-41 recurrence, the terminal pair is (6, 6), while the last-position pair is (6, 3). Both are legitimate two-component representations after selection, but only the first satisfies that terminal-state requirement.

Specify which sequence representation the consumer needs

An offline application may request one representation for a complete sequence, or features assigned to a particular input position. Calling either return a bidirectional summary leaves the selection unresolved. Begin with the downstream requirement: does it ask for the endpoint of each directional traversal, or for the two directional features aligned to one position?

PyTorch 2.14's RNN interface distinguishes output, the last layer's features at each input position, from h_n, the final hidden states. Forward and reverse are directions 0 and 1. Its batch_first option changes the input/output layout without changing hidden-state layout. An axis convention and a component's meaning therefore need separate descriptions.

The worked case below uses one complete, unpadded sequence and one recurrent layer. Variable-length padded inputs, packed sequences, multiple layers, GRUs and projected models require their own interface account; no selection rule for those cases is derived here.

References: [R1]

BI-41 fixes the inputs, weights and starting states

BI-41 is a fictional mathematical example of a bidirectional Elman RNN. The original input positions are 0, 1 and 2, with dimensionless scalar values x(0) = 1, x(1) = 2 and x(2) = 3. There is one batch element, input_size = hidden_size = 1, and all three inputs are available before this offline comparison.

Explicitly choose ReLU, which returns max(0, z), rather than the interface's default tanh. In each direction, stipulate an input-to-hidden weight of 1, a hidden-to-hidden weight of 1, and both biases equal to zero. Each direction starts from its own zero hidden state at its traversal boundary. These chosen parameters describe neither default initialization nor a trained model.

Write the forward recurrence as f(t) = max(0, x(t) + f(t − 1)), with f(−1) = 0. Write the reverse recurrence as b(t) = max(0, x(t) + b(t + 1)), with b(3) = 0. The indices refer to original input positions, so the reverse recurrence uses the already processed position to its right. The following values are derived arithmetic, not observed model outputs.

References: [R1]

Follow each traversal, then align features to original positions

The forward traversal visits positions 0, 1 and 2. It produces f(0) = max(0, 1 + 0) = 1, then f(1) = max(0, 2 + 1) = 3, then f(2) = max(0, 3 + 3) = 6. Its terminal state is f(2) = 6.

The reverse traversal visits positions 2, 1 and 0. It first produces b(2) = max(0, 3 + 0) = 3, then b(1) = max(0, 2 + 3) = 5, then b(0) = max(0, 1 + 5) = 6. Its terminal state is b(0) = 6. Written in original position order, the reverse features are therefore 6, 5 and 3.

The per-position output pairs a forward feature with the reverse feature at that same original position. The table aligns those features; its row order is the original input order, rather than the reverse traversal order.

References: [R1]

Scroll the table horizontally on smaller screens.

BI-41: directional features aligned to the three original input positions
Original positionInput x(t)Forward f(t)Reverse b(t)Output pairSource
0116(1, 6)Planning analysis
1235(3, 5)Planning analysis
2363(6, 3)Planning analysis

All values follow from BI-41's stipulated scalar recurrence. The forward endpoint is in row 2; the reverse endpoint is in row 0.

The two terminal states belong to different original positions

With BI-41's time-major input shape (3, 1, 1), output has shape (3, 1, 2): three positions, one batch element and two directional features. The final original-position pair is (f(2), b(2)) = (6, 3).

The raw h_n shape is (2, 1, 1), accounting for two directions, one layer, one batch element and one hidden component per direction. Selecting that batch element and ordering the terminal states as forward then reverse yields the conceptual pair (f(2), b(0)) = (6, 6). This pair has two scalar components; it is not the raw tensor's shape.

The reverse feature 3 at original position 2 has already consumed x(2). It is the first computed reverse feature, not the zero incoming boundary state b(3). Conversely, the last-position output is not restricted to the last input overall: its forward component 6 has traversed all three positions.

Selecting the entire first-position pair would give (1, 6), moving the incomplete traversal to the forward component. For this requirement, the desired components come from opposite ends of the original sequence. Changing which whole position is called last cannot supply both endpoints.

References: [R1]

A consumer expecting both terminal states receives 12

Now stipulate a separate consumer whose requirement is to add the two directional terminal summaries. With the required pair, it receives 6 + 6 = 12. Substituting the final original-position pair supplies 6 + 3 = 9. The consumer's arithmetic has not changed; the reverse component supplied to it has changed.

Imagine two fictional handoffs. Handoff P labels (6, 3) as the features at original position 2. That label accurately describes the position-level object. Handoff T labels (6, 6) as the ordered forward/reverse terminal pair. T satisfies the stipulated terminal-summary requirement; P would satisfy a request for the final position's two directional features.

A check for two numerical components would accept either selected pair. It cannot establish that the values have the required roles. The useful acceptance question is whether each component comes from the specified direction and traversal endpoint. Neither 12 nor 9 is a classifier score, recognition result or quality ranking in this example.

Complete traversal does not establish a lossless or better summary

Both terminal states have processed every BI-41 input, but the chosen weights reduce each to the same sum, 6. Reversing the input values to 3, 2 and 1 still produces the terminal pair (6, 6). The pair therefore cannot recover which of those two orders was supplied. Traversal coverage and preservation of individual input information are different properties.

The reverse features also rely on later original positions. In BI-41, b(0) uses positions 2 and 1 before position 0. This is an offline calculation with the complete input available; it supplies no evidence that the same features can be returned causally before those later inputs arrive.

PyTorch 2.14's LSTM documentation independently distinguishes the final forward/reverse hidden states from the last-position output. Its gated dynamics and separate cell state are different from BI-41's ReLU Elman recurrence. That related interface note supports the distinction between objects, not reuse of these numbers as an LSTM calculation.

Whether terminal states, position features or another specified representation best serves a real task requires evaluation of the actual model and consumer. BI-41 establishes the selection mismatch without supplying a prediction-quality, runtime or hardware-capacity result.

References: [R2]

Ask the software owner to identify the selected states

A useful delivery description names the model revision and framework version, the returned object, its raw shape and the selection that forms the consumer's representation. For each selected component, identify its recurrent layer, direction, batch element and original input position or traversal endpoint. State the input boundaries, initial hidden states and intended consumer alongside that description.

For a requirement like BI-41's, ask the owner to substantiate the forward terminal state and reverse terminal state separately, then show their order in the delivered pair. Evidence from the supplied implementation should connect a known input to those selected states and the consumer result. A shape declaration or the word bidirectional alone leaves that connection unresolved. A representation description explains the proposed behavior; it does not prove that the implementation performed it.

Keep the requirement explicit when resolving a discrepancy. A correctly identified last-position output may be useful for a position-level task. It needs a different selection to fulfill a promise of both directional endpoints. The appointed software owner should reconcile that selection with the consumer before treating the handoff as meeting the requirement.

The related padding guide addresses how input lengths and layout preserve valid positions; the embedding guide addresses the earlier lookup of vectors for input IDs. Here every input position is valid and the recurrence's scalar inputs are already given. The remaining decision is which computed states are delivered.

Scope separately needed equipment installation

If an independently selected equipment package needs physical installation, Leviathan's rack-and-stack service can discuss agreed equipment mounting, IT cabling, labels and installation handoff records. Use the related service and project inquiry with a nonconfidential equipment list, rack layout, site requirements and target window. Model representation, software implementation and application acceptance remain with the appointed software team; software commissioning is not a standard rack-installation inclusion.

References: [L1]

Primary sources

  1. [R1] PyTorch 2.14 — torch.nn.RNNChecked 2026-10-21. Defines the Elman recurrence, supported nonlinearities, per-position output, final hidden states, directional order and tensor layouts. BI-41 specializes the recurrence with explicitly chosen scalar parameters.
  2. [R2] PyTorch 2.14 — torch.nn.LSTMChecked 2026-10-21. The bidirectional note distinguishes final directional hidden states from last-position output. Its gates, cell state and projection-dependent dimensions are outside BI-41's numerical example.
  3. [L1] Leviathan Systems — Rack-and-Stack & Colocation InstallationChecked 2026-10-21. Defines agreed physical mounting, IT cabling, identification and handoff scope for a separately selected equipment project. Software commissioning is not a standard installation inclusion.

Does selected equipment need physical installation?

Share a nonconfidential equipment list, rack layout, site and required IT connections to discuss the physical installation scope and availability.

Discuss a ProjectEmail Project Scope