Windowed State-Recovery Training for Robust Recurrent Networks

Recurrent networks, which read a sequence one step at a time and carry a running memory called the hidden state, fail in a characteristic way under attack. A small perturbation on a few early steps can push the hidden state off course, and the network then stays wrong even after the input returns to normal. Adversarial training is the standard defense: the model is trained on worst-case perturbed inputs found by an inner optimization. For recurrent models it is very expensive, because every inner attack step must backpropagate through the whole sequence. We propose a cheaper target. Instead of attacking the full sequence, perturb only a short window. Instead of asking the model to keep its final label, train it so that its hidden state returns to the clean path within a few steps after the window ends. This keeps the inner attack local in time, so its cost depends on the window length rather than on the sequence length.

The bet is that, for recurrent classifiers, robustness to state hijacking is mostly a property of the step-to-step transition rule: whether a nudged state gets captured or recovers. A property of the transition rule can be trained on short segments. If the bet is right, we get robustness to full-length attacks at a fraction of the cost of full adversarial training. It would also explain a puzzling negative result: input-level adaptive perturbation scaling helps MLPs and Transformers but barely helps LSTMs ASAT. Because transfer attacks between recurrent models are naturally weak, we also treat transferability as an audit tool. It lets us check that any robustness we measure is real and not just gradients that have stopped carrying useful signal.

Core Claim

Let $h_t(x)$ be the hidden state after step $t$ on input $x$. For a window starting at step $s$ of length $w$, let $\delta$ be a perturbation that is nonzero only inside the window, with $\|\delta\|_\infty \le \epsilon$. The inner attack maximizes how far the state is pushed off its clean path over a recovery horizon of $r$ steps after the window closes:

$$D_s(\delta) = \sum_{t=s+w}^{s+w+r} \| h_t(x+\delta) - h_t(x) \|^2 .$$

The clean state $h_s(x)$ comes from a single gradient-free forward pass. So each inner step backpropagates through only $w+r$ steps instead of $T$. With the worst-case window perturbation $\delta^\star$ in hand, the outer update minimizes

$$L(f(x),y) + \lambda\, L(f(x+\delta^\star),y) + \mu\, D_s(\delta^\star),$$

where $L$ is the classification loss, $f$ the classifier, and $\lambda,\mu$ weights. The outer loss runs one full forward and backward pass. Per-step cost therefore drops from roughly $K\cdot T$ to $K(w+r) + 2T$ sequence-step passes, where $K$ is the number of inner attack iterations. For sequential MNIST, the pixel-by-pixel digit task with $T=784$, using $K=10$ and $w+r=64$, that is about 2,200 versus 7,840, roughly a 3.5× saving. The ratio grows with sequence length.

The central claim to test is not the saving itself. It is that models trained this way are robust to unrestricted full-sequence attacks, and that the state-recovery term $D_s$ is what makes window training carry over to them.

Grounding in Prior Work

Several papers motivate the locality assumption. Sparse Adversarial Perturbations for Videos shows that perturbing 8 of 40 frames of a CNN+LSTM video classifier fools it 100% of the time, and that one frame reaches nearly 60%. This is direct evidence that a short corrupted window can capture the state. It also finds LSTMs and GRUs more prone to this persistence than vanilla RNNs. We turn that attack observation into a training target. Dynamically Computing Adversarial Perturbations for Recurrent Neural Networks computes attacks step by step from the current state, treating the recurrence as a dynamical system. Its success with purely local, causal perturbations supports the idea that local state sensitivity is what matters. That work only attacks; we train against the same local quantity.

ASAT (paper) constrains our design. It rescales the perturbation budget across time steps, and its gains on LSTMs were marginal. We read this as evidence that shaping the input budget does not touch the failure mode that matters for recurrence, which is failure to recover. So our objective acts on hidden states rather than on input weights.

Smooth Gradient Method (SGM) training (Smooth Perturbations for Time Series Adversarial Attacks) shows that training on temporally smooth perturbations drives attack success rate near zero on the UCR archive. It does not address cost and reports no per-dataset accuracies. It is a competitor, not a mechanism we reuse.

The Lyapunov and dissipativity work (Robust Design of Deep Neural Networks against Adversarial Attacks based on Lyapunov Theory, Connecting Lyapunov Control Theory to Adversarial Attacks) avoids the inner loop entirely by bounding per-layer spectral norms in feedforward networks. Its recurrent analogue, forcing the transition map to contract, is our most serious rival. Our method is a data-driven, local version of contraction: it asks for recovery only along directions an attacker can actually reach, rather than everywhere. That is why it might keep long memory where a global contraction bound cannot.

On transferability, Demystifying Limited Adversarial Transferability in Automatic Speech Recognition Systems reports that recurrent components and sequence outputs suppress transfer: 42% in its control setup, 88% when the RNN is replaced by a CNN, and 4% for four-word phrases. This tells us that low transfer-attack success against a recurrent model is weak evidence of robustness. Q-TART shows, for image classifiers only, that a cheaper adversarial training scheme can also reduce transfer vulnerability. We ask the same question for recurrent models.

Research Program

We first build the method for LSTM and GRU classifiers and specify three choices. Window start $s$ is sampled uniformly, or biased toward early steps following the persistence evidence from sparse video attacks. Window length $w$ and horizon $r$ are swept, with $w+r$ held between 16 and 128. The state distance in $D_s$ is either Euclidean or weighted by the readout layer, so that state directions irrelevant to the label are not over-penalized.

Second, we run a mechanism analysis. For each trained model we measure a recovery time: inject a worst-case window perturbation and count the steps until $\|h_t(x+\delta)-h_t(x)\|$ falls below a threshold. We also measure memory retention on the clean long-horizon task, using sequential MNIST accuracy. The hypothesis is that our method lowers recovery time for attacker-reachable perturbations while preserving retention. A spectral contraction constraint should lower recovery time only by cutting retention.

Third, we run a transferability audit. Every trained model is attacked by transfer from three surrogate types: an undefended LSTM with a different initialization, a 1D CNN, and the distillation-plus-generator attack of Adversarial Attacks on Time Series. Each model also serves as a surrogate itself. This answers a question the file explicitly leaves open: whether adversarially hardened recurrent models produce more transferable attacks or less.

Baselines

The do-nothing reference is standard training of the same LSTM or GRU. We report clean accuracy and robust accuracy under our full evaluation suite. Undefended recurrent models are known to be badly exposed. The ODE attack flips UCI Human Activity Recognition (HAR) predictions with over 99% confidence at $\ell_\infty \le 0.15$ Dynamically Computing Adversarial Perturbations for Recurrent Neural Networks, and a single perturbed frame reaches nearly 60% fooling on UCF101 Sparse Adversarial Perturbations for Videos.

The strongest existing method is full-sequence multi-step projected gradient descent (PGD) adversarial training, the standard min-max scheme in which every inner step backpropagates through all $T$ steps. It is the most direct competitor because our method claims to approximate it at lower cost. We find no reported result on Lacuna for robust accuracy of full PGD adversarial training of LSTMs on UCR, HAR, sequential MNIST, or Speech Commands. We will therefore run it ourselves with the same architecture, $\epsilon$, epochs, and hyperparameter search budget, and treat it as the robustness ceiling. Beating it means matching its full-sequence PGD robust accuracy within one percentage point, at no worse clean accuracy, with at least 2.5× lower training wall-clock on sequences with $T \ge 500$.

SGM adversarial training is the strongest published time-series-specific defense. Its reported result is qualitative: "near-zero Average Success Rate" across UCR. We find no reported number for its clean or robust accuracy on Lacuna, so we rerun it on the same UCR subset.

ASAT is run as the adaptive-scaling baseline, since the file reports only that its LSTM gains were "marginal" with no figures. The spectral-contraction baseline constrains the recurrent weight matrix to have spectral norm below one, in the spirit of the Lyapunov work. Its only feedforward number in the file is about 38% versus 34% for ResNet50 on ImageNet under FGM at $\epsilon = 0.4$, which is not comparable to our setting. Single-step adversarial training uses the fast gradient sign method (FGSM) over the full sequence, a one-step attack.

The key ablation is windowed PGD with only the label loss and $\mu=0$. It costs about the same as our method but drops the recovery objective. If it matches our method, the recovery term is not the active ingredient.

All methods share data splits, architectures, and the number of tuning trials. We report results both at equal epochs and at equal wall-clock.

Why not just…?

Why not just use single-step FGSM adversarial training over the full sequence? It is cheap, about $2T$ passes per step, and it is a real threat on short UCR series. The file's evidence against it is indirect. Sequential vulnerability compounds over steps, and uniform budgets are poorly suited to time-indexed features ASAT. Still, neither point shows that FGSM training fails. We settle it empirically at matched wall-clock against multi-step full-sequence PGD and sparse attacks, the kind of attack single-step training typically handles poorly. If FGSM matches us, we will report that.

Why not just make the recurrence contractive with a spectral-norm bound, with no inner loop at all? This is the most principled cheap alternative, extending Robust Design of Deep Neural Networks against Adversarial Attacks based on Lyapunov Theory. Its likely weakness is that global contraction erases long-range memory, the very property sequential MNIST and four-word speech commands require. The retention-versus-recovery analysis tests exactly this. If contraction reaches comparable robust accuracy without losing clean long-horizon accuracy, our method is unnecessary.

Why not just run truncated windowed PGD with the ordinary label loss? This is the ablation above, and it isolates our claim. Our prediction is that it yields robustness to windowed attacks that does not carry over to full-sequence attacks. With a label loss, perturbations early in the sequence are scored only through the final output, so they receive a weak training signal, while the recovery term targets state capture directly.

Why not just smooth or filter the input? SGM shows that attackers can optimize smooth perturbations that pass filters Smooth Perturbations for Time Series Adversarial Attacks. A single-frame attack seeds the state before any sequence-level filter can act. We include a low-pass preprocessing baseline only as a sanity check.

Proposed Experiments and Decisive Checks

The benchmarks span short to long sequences, since the predicted saving grows with sequence length:

  • UCR Time Series Archive: the ten univariate datasets used by TSFool, including ECG200 and CBF.
  • UCI HAR: nine-channel inertial sensor data.
  • Sequential MNIST: $T=784$. The adversarial-dropout paper reports 0.644% clean error with an LSTM Adversarial Dropout for Recurrent Neural Networks, which serves as a clean-accuracy reference.
  • Google Speech Commands: one-word and four-word variants, following the transferability study.

The metrics are:

  • clean accuracy;
  • robust accuracy under the worst of full-sequence PGD with 100 steps and restarts, the sparse attack from the video paper, SGM, the ODE attack, and TSFool;
  • transfer-attack success from each surrogate;
  • training wall-clock and peak memory;
  • recovery time.

There are four decisive checks. The first is carry-over: robust accuracy under unrestricted full-sequence PGD must approach full PGD adversarial training, not merely the windowed-attack accuracy we trained for. The second is gradient masking: transfer attacks from a CNN surrogate must not succeed more often than white-box attacks. Given the 88% CNN-to-RNN transfer gap reported for speech, a model whose white-box robustness exceeded its transfer robustness would be flagged as masked. The third is the ablation: removing the recovery term must cost robust accuracy at matched compute. The fourth is scaling: the wall-clock advantage over full PGD adversarial training should grow with $T$, from UCR to sequential MNIST.

The idea fails cleanly if windowed models remain broken by full-sequence attacks. That outcome would itself show that recurrent vulnerability is not local in time, which runs against the persistence picture drawn from the sparse-attack literature.