Skip to main content

Recurrent Layer Ontology

Neural Network Entities
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 28 October 2026
Audio Overview
FLOW ALGEBRA — RECURRENT LAYER ONTOLOGY
Semantic Library | AI Core > Entity Graph > AI Entities > Neural Network Entities
Source: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/neural-network-entities/recurrent-layer-ontology.html
Status: Original companion formalisation; source-page contents not independently verified.
Date: 2026-10-28
Authors: Kireth Research; Sky — Recursive AI (companion formalisation)

1. PURPOSE
Represent a recurrent neural-network layer as a stateful, parameterised transformation of a sequence. Specify temporal state, inference, training, causal constraints, validation, and its position within an AI entity graph.

2. ENTITY AND RELATIONSHIP MODEL
Entity: RecurrentLayer
Parent: NeuralLayer
Related: ArtificialNeuron, NeuralWeight, NeuralBias, ActivationFunction, HiddenLayer, OutputLayer, LossFunction, GradientEntity.
Properties: layer_id, architecture, input_dim, hidden_dim, parameters, initial_state_policy, sequence_mask, precision, device, training_mode.
Relations:
  hasInput -> SequenceTensor
  hasHiddenState -> StateTensor
  hasParameters -> ParameterSet
  appliesActivation -> ActivationFunction
  produces -> OutputSequence
  trainedWith -> LossFunction
  updatedBy -> Optimiser
  precedes/follows -> NeuralLayer

3. FORMAL STATE MODEL
S_t = (I_t, R_t, B_t, K_t)
I_t = (x_t, h_(t-1), optional c_(t-1), mask_t)
R_t = (W_x, W_h, b, activation, recurrence, output_projection)
B_t = (sequence_order, valid_shape, finite_values, causal_policy, resource_limits)
K_t = (architecture_metadata, learned_parameters, initialisation_policy, provenance)
E_t = expand(I_t, R_t)
V_t = {e in E_t | constraints_B_t(e) = true}
a_t = argmax_{a in V_t} P(a | I_t, R_t, B_t, K_t)  [only when a probabilistic selection policy is defined]
I_(t+1) = update(I_t, a_t, observation_(t+1))
Note: ordinary recurrent forward computation is deterministic given inputs, state and parameters; argmax is an optional selection layer, not a required RNN operation.

4. RECURRENT COMPUTATION
Vanilla RNN:
  z_t = W_x x_t + W_h h_(t-1) + b
  h_t = phi(z_t)
  y_t = g(W_y h_t + b_y)  [if an output projection is present]
Shapes: x_t in R^d, h_t in R^h, W_x in R^(h x d), W_h in R^(h x h), b in R^h.
Unrolled recurrence: h_T = F_theta(x_T, F_theta(x_(T-1), ... F_theta(x_1, h_0))).
Gated variants (LSTM/GRU) require architecture-specific gate equations; they must not be treated as interchangeable with the vanilla recurrence.

5. SEQUENCE AND TRAINING FLOW
Input sequence X=(x_1,...,x_T)
 -> validate dimensions and mask
 -> initialise h_0 (and c_0 where applicable)
 -> iterate t=1..T: recurrent transition
 -> collect outputs and final state
 -> compute task loss L(theta; X, targets)
 -> backpropagation through time (BPTT)
 -> optional gradient clipping
 -> optimiser update theta' = theta - eta * grad_theta L  [SGD example]
 -> evaluate on held-out sequences
 -> version and record provenance.
Truncated BPTT limits the backward horizon; it is not equivalent to full-sequence gradient propagation.

6. INFERENCE RULES
R1: IF dimensions are incompatible THEN reject the operation.
R2: IF timestep is masked THEN apply the documented state carry/skip policy.
R3: IF causal inference is required THEN prohibit dependence on future inputs.
R4: IF state is retained between requests THEN identify session and reset boundaries explicitly.
R5: IF gradient norm exceeds configured threshold THEN clip or reject according to policy.
R6: IF non-finite activations occur THEN fail validation and record diagnostic evidence.
R7: IF bidirectional recurrence is selected THEN do not claim streaming causality without buffering or a revised definition.
R8: IF inference uses a different initial-state policy from training THEN flag distribution mismatch.

7. TRI-MAPPING
Ontology: RecurrentLayer --maintains--> HiddenState
Mathematics: h_t = F_theta(x_t, h_(t-1))
Execution: state = recurrent_cell(input[t], state, theta)

8. MAPPING TABLE
Concept | Mathematical object | Runtime representation
Input sequence | X in R^(T x d) | tensor / padded batch
Hidden state | h_t in R^h | state tensor
Recurrent weights | W_h | trainable matrix
Input weights | W_x | trainable matrix
Bias | b | trainable vector
Transition | F_theta | recurrent cell
Loss | L(theta) | differentiable scalar
Gradient | grad_theta L | autodiff tensor set
Mask | m_t in {0,1} | padding/validity mask

9. SYSTEM DIAGRAM
x_1 ---> [CELL theta] ---> h_1
             ^              |
             | h_0          v
x_2 -----------------> [CELL theta] ---> h_2
                              |             |
                              +---- ... ----+
                                            v
x_T ----------------------> [CELL theta] -> h_T -> output
Shared parameters theta across time steps.

10. SAFETY AND CORRECTNESS INVARIANTS
- Hidden-state shape remains consistent across timesteps.
- Every recurrent transition respects the declared sequence mask policy.
- Parameter sharing across timesteps is explicit.
- Training gradients are calculated only over the declared computation graph/horizon.
- No unsupported claim of stability, convergence, robustness or safety is inferred from architecture alone.
- Stateful inference must isolate user/session data and obey retention policy.
- Numerical overflow, exploding gradients and vanishing gradients are monitored where relevant.

11. CONDITIONAL EXECUTION GUARANTEE
Given compatible tensors, finite inputs and parameters, a well-defined transition function, sufficient resources and an implemented numerical backend, the layer produces an output or an explicit error. This is an interface-level conditional guarantee, NOT a guarantee of predictive accuracy, learning convergence, real-time latency or safety in every deployment.

12. AI SEARCH FLOW
FLOW_ID: neural-network.recurrent-layer.v1
ENTITY: RecurrentLayer
ALIASES: [RNN layer, recurrent neural layer, sequence recurrence layer]
INTENT: [define, classify, compute, train, compare, validate, trace]
INPUTS: [sequence, initial_state, parameters, mask, architecture]
OUTPUTS: [output_sequence, final_state, diagnostics]
PATHWAYS:
  define -> entity_model -> relations
  compute -> validate -> initialise -> recurrent_transition -> output
  train -> forward -> loss -> BPTT -> gradient_policy -> update
  compare -> vanilla_RNN / LSTM / GRU / bidirectional_RNN
  validate -> shape / causality / numerical_finiteness / state_isolation
SEMANTIC_EQUIVALENCE:
  'recurrent layer' ~= 'RNN layer' [context dependent]
  'recurrent layer' != 'attention layer'
  'hidden state' != 'trainable weight'
CONFIDENCE: conditional_on_source_and_runtime_evidence
UPDATE_MODEL: versioned; preserve architecture, tensor shapes, parameter provenance and evaluation results.
CITATION_BACKLINK: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/neural-network-entities/recurrent-layer-ontology.html

END OF FLOW
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ