N-HiTS Model & General Slope Attack (GSA)
- N-HiTS Model is a deep learning forecaster that predicts multi-step future values from time-series data, often applied in financial modeling.
- GSA employs an iterative gradient-based optimization under ℓ∞ constraints to precisely adjust the forecast endpoint slope with minimal perturbation.
- Empirical evaluations show that GSA can double or reverse forecast trends while maintaining forecast accuracy and evading detection by standard discriminators.
The General Slope Attack (GSA) is a targeted adversarial attack methodology developed for time-series forecasting models, specifically designed to manipulate the trend of predictions, such as those produced by an N-HiTS deep learning model. By optimizing a bespoke loss that encodes the desired change in the slope of the multi-step forecast, GSA enables fine-grained trend manipulation with minimal input perturbation, maintaining a high degree of stealth against typical discrimination mechanisms (Luszczynski, 24 Nov 2025).
1. Formal Definition and Problem Setup
In the GSA framework, the attacker operates under a white-box setting with full access to the target model, typically an N-HiTS forecaster . The input is a time-series vector (e.g., the last days of adjusted stock prices), and the model outputs a multi-step forecast for future time points.
The goal is to construct a perturbed input obeying the constraint , where is typically a small fraction (e.g., ) of the median price. The key objective is to ensure that the slope, defined as
(where and represent the first and last forecasted values), is significantly altered, typically either doubled, reversed, or flattened, while the input perturbation remains imperceptible.
A target direction is used to control whether the attack aims to increase, flatten, or decrease the slope.
2. Optimization Formulation and Loss Construction
The attack is formulated as minimizing a slope-focused loss function under an -norm constraint on the input perturbation: The slope loss depends on the target direction :
- For (increase or decrease slope):
- For (flatten trend):
Here, and act as scaling hyperparameters. The exponentiated loss formulation for accelerates convergence toward the targeted slope direction.
3. Iterative Gradient-Based Attack Algorithm
GSA employs an iterative, projected gradient approach to optimize the adversarial perturbation. The algorithm proceeds as follows for iterations:
- Enable gradient computation on the current adversarial input .
- Compute the model's forecast .
- Calculate the empirical slope .
- Evaluate the loss .
- Backpropagate to compute the gradient .
- Update using .
- Project to satisfy the constraint: .
- Detach gradients.
- Repeat for steps, returning as the attacked sample.
Key hyperparameters:
- : Maximum perturbation per feature, typically of the median adjusted price.
- : Number of iterations, typically $20$–$50$.
- : Step size, suggested as .
- : Loss scaling and sensitivity parameters.
- : Trend direction target.
4. Empirical Evaluation and Trends
Extensive tests on financial time-series using an N-HiTS forecaster validate the effectiveness of GSA. Representative results, using of median price, , , , , and or $0$, demonstrate key characteristics:
| Attack | MAE | RMSE | MAPE | Gen. Slope | LS. Slope |
|---|---|---|---|---|---|
| Normal (no attack) | 2.15 | 2.72 | |||
| FGSM | 2.57 | 3.21 | |||
| BIM | 3.38 | 3.99 | |||
| TIM (Up) | 2.49 | 3.21 | |||
| GSA (Up) | 2.26 | 2.88 | |||
| GSA (Down) | 2.23 | 2.83 |
GSA (Up) achieves a near doubling of the endpoint slope (from $0.0337$ to $0.0676$) with minimal impact on mean absolute error or RMSE. GSA (Down) reverses the forecast trend. The increase in slope scales approximately linearly with . A plausible implication is that GSA's targeted perturbation mechanism provides efficient and precise trend manipulation with relatively undetectable modifications to the input.
5. Stealth and Evasion Properties
GSA is characterized by high stealth. When a four-layer CNN discriminator attempts to differentiate GSA-perturbed from clean inputs, it attains only specificity and overall accuracy, approximating random guessing. This suggests that GSA exploits model-specific vulnerabilities without introducing artifacts easily identifiable by adversarial detectors. Notably, because the loss term exclusively involves the forecast endpoints, the perturbations minimally impact the middle-slice forecast values, further enhancing detectability resilience.
6. Comparative Analysis with Prior Adversarial Approaches
Compared to classical adversarial methods such as FGSM, BIM, and MI-FGSM—which maximize pointwise errors (e.g., MAE) and do not consider trend manipulation—GSA induces explicit and significant changes in the prediction trend. The Temporal-Intensity Manipulation (TIM) method, in contrast, requires specifying an ad-hoc per-timestep target or scalar shift, affecting the forecast pattern more globally but lacking direct slope control.
Distinctive GSA properties include:
- Direct optimization of the forecast's endpoint slope rather than generating a full synthetic target.
- Fine-grained control over trend direction and magnitude (e.g., exact slope doubling).
- Preservation of forecast shape in regions away from the endpoints, improving stealth.
- Lightweight computational burden relative to adversarial sample construction alternatives.
7. Applications and Security Implications
GSA represents a practical tool for both evaluating adversarial robustness and probing security in financial time-series forecasting. Its integration into a generative adversarial network (GAN) architecture has been demonstrated for generating realistic, adversarial synthetic data capable of simultaneously deceiving both forecaster and discriminator. Demonstrations also include the use of adversarial malware capable of manipulating inputs at the inference library level, highlighting the need for comprehensive machine learning security that encompasses the entire deployment pipeline, beyond model-level defenses (Luszczynski, 24 Nov 2025).