Contextual Activation Functions: A Unified Framework for Context-Dependent Neural Computation in Temporal Systems

Standard neural networks rely on fixed elementwise activation functions, which assume that the nonlinear response is stationary and independent of context. Yet many real-world tasks are inherently regime-dependent: the appropriate computation may vary with external signals such as time, system state, or task identity, as in sequential modeling, adaptive control, and multi-task learning.We introduce contextual activation functions (CAF) as a foundational family of adaptive activation maps in which the nonlinear response becomes explicitly driven by an exogenous context. Given a pre-activation vector a ∈ ℝᴴ and a context vector s ∈ ℝˢ, the canonical pure CAF operator isΦₚᵤᵣₑ(a, s) = g(a, s) ⊙ ρ(a),g(a, s) = σ(Wg[a; s] + bg) ∈ (0, 1)ᴴ,where ρ is a scalar base activation applied componentwise and g is a learnable sigmoid gate. Rather than proposing a single model, we establish the fundamental analytic properties of this family: we derive the Jacobian of the operator—which decomposes into a gated diagonal term and a gate-induced coupling term—and use it to characterize local sensitivity, gradient propagation, and conditioning. Under separate smoothness, boundedness, and Lipschitz assumptions, we establish the corresponding regularity and stability properties, and we characterize gradient attenuation in saturated gating regimes. From an approximation-theoretic standpoint, on every compact product domain Kₐ × Kₛ, the uniform closure of the affine-gate pure-CAF family contains the standard activation map and also contains genuinely context-dependent maps.One-hidden-layer pure CAF networks preserve universal approximation; more substantively, universality already holds for the restricted subfamily in which the base pre-activation depends only on the primary input x and the gate depends only on the context s. We characterize standard activations as limiting cases and describe context-only, diagonal, and full gates as structured members of the CAF family, and we quantify the parametric and computational overhead, which scales as O(H² + HS) per layer for full affine gating and linearly in the context dimension S.We finally derive an exact finite-sample risk identity for a target-profiled linearized surrogate used to compare an exogenous gate channel with a fitted self-gated member. Under explicit profiling, transportability, covariance, regularization, and Taylor-remainder assumptions, the identity yields a local selection rule. Transfer to an actually re-optimized nonlinear network additionally requires a profile-alignment condition, and prospective empirical validation is left to future work. The criterion separates the target-distribution approximation gain, ridge shrinkage bias, and estimation variance for the profiled linearized surrogate under explicit profiling and transportability assumptions. Its transfer to the nonlinear retrained network requires an additional profile-alignment bound and a controlled Taylor remainder. We provide estimable diagnostics and a sample-splitting protocol, while leaving prospective empirical validation of the criterion to future work.As a behavioral study rather than a performance race, we also evaluate recurrent CAF forecasters on Solar, Bike, EPF-NP, and one target sensor from METR-LA under history-only and known-future-context contracts, using local recurrent references, persistence-matched specialized architectures, structural ablations, and a state-preserving extension; the results show dataset- and regime-dependent competitiveness rather than universal predictive dominance.

Authors

Publication Details

Journal
Research Square
Published
2026-11-23
DOI
https://doi.org/10.21203/rs.3.rs-11271506/v1
Primary Topic
Neural Networks and Applications
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
preprint

Contextual Activation Functions: A Unified Framework for Context-Dependent Neural Computation in Temporal Systems

Mohamed Ben Ammar Chraiti
Research Square
Neural Networks and Applications
preprint

Contextual Activation Functions: A Unified Framework for Context-Dependent Neural Computation in Temporal Systems

Mohamed Ben Ammar Chraiti
preprint en

Abstract

Standard neural networks rely on fixed elementwise activation functions, which assume that the nonlinear response is stationary and independent of context. Yet many real-world tasks are inherently regime-dependent: the appropriate computation may vary with external signals such as time, system state, or task identity, as in sequential modeling, adaptive control, and multi-task learning.We introduce contextual activation functions (CAF) as a foundational family of adaptive activation maps in which the nonlinear response becomes explicitly driven by an exogenous context. Given a pre-activation vector a ∈ ℝᴴ and a context vector s ∈ ℝˢ, the canonical pure CAF operator isΦₚᵤᵣₑ(a, s) = g(a, s) ⊙ ρ(a),g(a, s) = σ(Wg[a; s] + bg) ∈ (0, 1)ᴴ,where ρ is a scalar base activation applied componentwise and g is a learnable sigmoid gate. Rather than proposing a single model, we establish the fundamental analytic properties of this family: we derive the Jacobian of the operator—which decomposes into a gated diagonal term and a gate-induced coupling term—and use it to characterize local sensitivity, gradient propagation, and conditioning. Under separate smoothness, boundedness, and Lipschitz assumptions, we establish the corresponding regularity and stability properties, and we characterize gradient attenuation in saturated gating regimes. From an approximation-theoretic standpoint, on every compact product domain Kₐ × Kₛ, the uniform closure of the affine-gate pure-CAF family contains the standard activation map and also contains genuinely context-dependent maps.One-hidden-layer pure CAF networks preserve universal approximation; more substantively, universality already holds for the restricted subfamily in which the base pre-activation depends only on the primary input x and the gate depends only on the context s. We characterize standard activations as limiting cases and describe context-only, diagonal, and full gates as structured members of the CAF family, and we quantify the parametric and computational overhead, which scales as O(H² + HS) per layer for full affine gating and linearly in the context dimension S.We finally derive an exact finite-sample risk identity for a target-profiled linearized surrogate used to compare an exogenous gate channel with a fitted self-gated member. Under explicit profiling, transportability, covariance, regularization, and Taylor-remainder assumptions, the identity yields a local selection rule. Transfer to an actually re-optimized nonlinear network additionally requires a profile-alignment condition, and prospective empirical validation is left to future work. The criterion separates the target-distribution approximation gain, ridge shrinkage bias, and estimation variance for the profiled linearized surrogate under explicit profiling and transportability assumptions. Its transfer to the nonlinear retrained network requires an additional profile-alignment bound and a controlled Taylor remainder. We provide estimable diagnostics and a sample-splitting protocol, while leaving prospective empirical validation of the criterion to future work.As a behavioral study rather than a performance race, we also evaluate recurrent CAF forecasters on Solar, Bike, EPF-NP, and one target sensor from METR-LA under history-only and known-future-context contracts, using local recurrent references, persistence-matched specialized architectures, structural ablations, and a state-preserving extension; the results show dataset- and regime-dependent competitiveness rather than universal predictive dominance.

Research Square
Neural Networks and Applications
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon