[ENH] Merge `Flatten_Head` into `FlattenHead` with individual and `n_quantiles` support #2508
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 389 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.357
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #2508"
general
weight: 0.35
phoeenniixx
Description:
Summary
- Unified two near-identical flatten-head layers into a single FlattenHead in layers/_output/_flatten_head.py by adding an individual parameter
(defaults to False, preserving all existing behaviour for TimeXer and PatchTST).
- Updated ModernTCN to import and use the unified FlattenHead instead of the now-deprecated Flatten_Head.
- Replaced layers/_head/_flatten_head.py with a thin deprecated alias (Flatten_Head) that emits a DeprecationWarning and delegates to
FlattenHead, preserving backward compatibility for any external code.
- Added unit tests covering all four combinations of individual={True, False} × n_quantiles={None, k}, module-structure assertions, and the
deprecated-alias round-trip.
Motivation
Having two classes with different names and disjoint feature sets was confusing and prevented models like ModernTCN from benefiting from quantile
outputs via the head. The merge gives both features to all models from a single, well-documented class.
Breaking changes
None for public API consumers. The only internal behaviour change is in ModernTCN.forward, where one .permute(0, 2, 1) was added after the head
call to account for the now-consistent (B, target_window, n_vars) output shape — the final model outputs are identical.
Closes #2507