This repository contains the implementation and technical report for PirateNet, a compact hybrid deep learning architecture designed for multivariate time-series classification.
This project was developed by team AI: Accidentally Intelligent for the first challenge of the Artificial Neural Networks and Deep Learning (AN2DL) course at Politecnico di Milano (November 2025).
The objective of this challenge is to assign multivariate time-series sequences of sensor data into three pain categories: high_pain, low_pain, or no_pain.
- Multivariate Sequences: Each sample is a sequence of 160 time steps with several dynamic sensor channels.
- Static Attributes: Three categorical features (
n_legs,n_hands,n_eyes). - Main Difficulties:
- Strong class imbalance dominated by the
no_painclass. - Temporal locality (pain patterns appear as short events within longer neutral segments).
- High scale and sign variability across channels.
- Strong class imbalance dominated by the
PirateNet is a compact CNN→BiGRU model enhanced with temporal attention and a hybrid pooling strategy. It balances high accuracy with computational simplicity.
- Conv1D Stem: Extracts local temporal patterns from the raw sequence.
- Residual Blocks + SE Units: Dilated residual blocks with Squeeze-and-Excite (SE) units for adaptive multi-scale channel weighting.
- Bidirectional GRU (BiGRU): Captures long-range temporal dependencies.
- Temporal Attention Layer: Improves temporal credit assignment for short-duration pain bursts.
- GRU-Hidden Pooling: A custom mechanism that concatenates mean-pooled sequence features with the final GRU hidden state to capture both global statistics and end-state dynamics.
- Standardization: Normalization of dynamic sensor channels.
- Signed-Log Transform: Stabilizes long-tailed sensor values without losing sign information.
- First-Order Derivatives: Captures the rate of change across time without inflating dimensionality.
- One-Hot Encoding: Applied to the static categorical variables.
-
Loss Function: Focal Loss (
$\gamma = 1.5$ ) to improve minority-class recall without over-suppressing easy samples. - Optimizer: AdamW with a cosine learning-rate schedule and warmup.
- Regularization: Light jitter, channel-wise scaling, and 5-fold stratified cross-validation. Test-Time Augmentation (TTA=3) was used during inference.
The model was evaluated using the Macro F1 Score to account for the highly imbalanced dataset. PirateNet achieved the following validation metrics:
| Metric | Score |
|---|---|
| Accuracy | 0.935 |
| Macro F1 | 0.869 |
| Log Loss | 0.267 |
| Class | Precision | Recall | F1-Score |
|---|---|---|---|
high_pain |
0.786 | 0.786 | 0.786 |
low_pain |
0.885 | 0.819 | 0.851 |
no_pain |
0.959 | 0.973 | 0.966 |