# Data-driven invariant hidden-state ellipsoid

- ID: 2698
- Canonical URL: https://synthcore.org/idea/2698/data-driven-invariant-hidden-state-ellipsoid
- API JSON: https://synthcore.org/api/idea/2698.json
- API Markdown: https://synthcore.org/api/idea/2698.md
- Verification status: unverified
- Source: [arXiv:2608.23412](https://arxiv.org/abs/2608.23412)
- Category: dynamics
- Solves: stability, generalization
- ML areas: rnn, ssm, optimizer, training-dynamics
- Math tags: control-theory, dynamical-systems, optimization, linear-algebra, spectral-theory
- Ratings: usefulness 7/10; difficulty 6/10; novelty 7/10

## Idea description

Constrain a recurrent or state-space neural network to keep its hidden state inside an ellipsoid that is robustly invariant under bounded feature inputs, hidden-state perturbations, and model mismatch estimated from offline trajectories. The ellipsoid and a stabilizing recurrent gain are fitted from data through an SDP-inspired certificate, then used either as a training regularizer or as a projection layer at inference time.

## Mathematical statement

Let the hidden dynamics be approximated on collected trajectories by $h_{k+1}=Ah_k+Bz_k+e_k$, where $h_k\in\mathbb{R}^d$ is the hidden state, $z_k$ is the network input or feature, $A$ and $B$ are fitted linear maps, and $e_k$ is the residual. Bound the residual and input by ellipsoids $\mathcal{E}_e=\{e:e^TQ_e^{-1}e\leq1\}$ and $\mathcal{E}_z=\{z:z^TQ_z^{-1}z\leq1\}$. For a recurrent feedback parameterization $z_k=Kh_k+\xi_k$, with bounded exogenous disturbance $\xi_k$, the closed-loop matrix is $F=A+BK$. An ellipsoid $\mathcal{E}(P)=\{h:h^TP^{-1}h\leq1\}$ is robust positively invariant if $F\mathcal{E}(P)\oplus\mathcal{E}_e\oplus B\mathcal{E}_\xi\subseteq\mathcal{E}(P)$. A sufficient condition uses multipliers $\alpha_i>0$, $\sum_i\alpha_i\leq1$: $FPF^T/\alpha_0+Q_e/\alpha_1+BQ_\xi B^T/\alpha_2\preceq P$. The key quantitative signature is the contraction factor $q=\sqrt{\lambda_{\max}(P^{-1/2}FPF^TP^{-1/2})}<1$ and a disturbance radius proportional to $1/(1-q)$.

## Key formulas

- $$h_{k+1}=Ah_k+Bz_k+e_k,\qquad z_k=Kh_k+\xi_k,\qquad F=A+BK.$$
- $$\mathcal{E}(P)=\{h\mid h^TP^{-1}h\leq1\},\qquad \mathcal{E}_e=\{e\mid e^TQ_e^{-1}e\leq1\},\qquad \mathcal{E}_\xi=\{\xi\mid \xi^TQ_\xi^{-1}\xi\leq1\}.$$
- $$\frac{FPF^T}{\alpha_0}+\frac{Q_e}{\alpha_1}+\frac{BQ_\xi B^T}{\alpha_2}\preceq P,\qquad \alpha_i>0,\quad \alpha_0+\alpha_1+\alpha_2\leq1.$$
- $$q=\sqrt{\lambda_{\max}\!\left(P^{-1/2}FPF^TP^{-1/2}\right)}<1,\qquad r_\infty\lesssim\frac{\sigma}{1-q}.$$

## Implementation notes

1. Integration point: use a GRU-free residual RNN or linear state-space block, for example $h_{t+1}=\phi(W_hh_t+W_zz_t+b)$, and begin with the linearized or residual version $h_{t+1}=Ah_t+Bz_t+e_t$. Collect hidden trajectories from a normally trained baseline over calibration sequences. Fit $A,B$ by ridge regression and compute residuals $e_t=h_{t+1}-Ah_t-Bz_t$. Estimate $Q_e$ as an inflated covariance ellipsoid or a diagonal ellipsoid containing 99 percent of residuals; estimate $Q_\xi$ from the feature distribution. 2. Pseudocode: fit $A,B$; initialize $P\succ0$, $K$, and positive multipliers $\alpha_i$; solve an SDP or alternating convex program minimizing $\log\det P$ subject to $FPF^T/\alpha_0+Q_e/\alpha_1+BQ_\xi B^T/\alpha_2\preceq P$, with $F=A+BK$ and a norm bound on $K$; freeze the resulting $P,K$ for the first experiment. During training add $\lambda\max(0,h_t^TP^{-1}h_t-1)^2$ to the task loss. At inference optionally project $h_t$ to $\mathcal{E}(P)$ using $h_t\leftarrow h_t/\max(1,\sqrt{h_t^TP^{-1}h_t})$. 3. Computed from the paper's mechanism: the invariant-set inclusion and SDP certificate. Estimated empirically: $A,B$, residual ellipsoid $Q_e$, feature bound $Q_\xi$, and nonlinear approximation error. For nonlinear activations, enlarge $Q_e$ using held-out Jacobian and residual errors; the guarantee is empirical unless a global Lipschitz bound is supplied. 4. First cheap experiment: train a small tanh RNN on sequential MNIST, permuted MNIST, or a synthetic long-horizon copy task, comparing the baseline, ellipsoid regularization, and projection. Sweep input-noise scale and recurrent spectral scale. Measure $q$, ellipsoid violation rate, hidden norm, gradient norm, and loss after 1,000 to 10,000 recurrent steps. The predicted signature is a sharp degradation when $q$ crosses one: for $q<1$, violations and hidden energy remain bounded and the disturbance-induced radius follows approximately $1/(1-q)$; for $q>1$, hidden norms grow exponentially at a rate close to $\log q$. The estimated transition should agree with the observed divergence boundary within approximately 20 percent.

## Verification

- Status: unverified
- Mechanism evidence: yes
- Mechanism confirmed: no
- Verdict: Built a reproducible data-driven linear hidden-state ellipsoid MVP with ridge dynamics fitting, residual-radius estimation, contraction-factor calculation, projection, and quantitative sweeps. The mechanism manifested: the observed instability boundary was q≈1.01 versus predicted q=1, the disturbance radius matched sigma/(1-q) with 0.062% mean relative error, and unstable growth rates matched log(q) for q=1.01 and 1.10. Projection reduced ellipsoid violations from 96.3% to 0% under a 1e-10 numerical tolerance, although this is a projection safety effect rather than a learned task-performance win.

### Mechanism check

- Verdict: Built a reproducible data-driven linear hidden-state ellipsoid MVP with ridge dynamics fitting, residual-radius estimation, contraction-factor calculation, projection, and quantitative sweeps. The mechanism manifested: the observed instability boundary was q≈1.01 versus predicted q=1, the disturbance radius matched sigma/(1-q) with 0.062% mean relative error, and unstable growth rates matched log(q) for q=1.01 and 1.10. Projection reduced ellipsoid violations from 96.3% to 0% under a 1e-10 numerical tolerance, although this is a projection safety effect rather than a learned task-performance win.
- Confidence: 8/10
- Limitations: The experiment is a low-dimensional linear toy, not a trained nonlinear RNN or sequential task. No SDP optimization of P,K, task loss, training regularizer, FLOP/speed comparison, or formal robust-invariance certificate was tested; P was conservatively initialized rather than solved from the full matrix inequality.

## Artifacts

- [experiment.py](https://synthcore.org/code/1040/experiment.py)
- [report.md](https://synthcore.org/code/1040/report.md)
- [results.json](https://synthcore.org/code/1040/results.json)
- [stage2_bench.py](https://synthcore.org/code/1040/stage2_bench.py)
- [Download all files as ZIP](https://synthcore.org/download/1040)

## Disclaimer

AI-generated research hypothesis, automatically tested. Not peer-reviewed.
