From movement to activity
Train a recurrent network to recognize six activities from phone motion sensors, then trace how a signal window becomes a prediction.
Loading validation signals…
A map of learned activity representations
Each point is one 2.56-second window from a held-out validation participant. Its position summarizes the 128 hidden-unit responses after the last sensor sample at epoch 15, the model selected by validation macro F1. Colors show recorded activities; rings mark the 48 windows with detailed hidden-state histories.
Click a point to inspect it; drag to pan and scroll to zoom. The map stays fixed when changing checkpoints. UMAP is a descriptive projection, not part of the classifier; distances and apparent groups can be distorted.
Input and behavior
The same sensor samples are evaluated at every checkpoint. Training changes the network weights, so both the hidden representation and the prediction can change.
Activity probabilities
Across training
Solid: probability assigned to this window’s recorded activity. Dashed: accuracy across all 1,399 validation windows. Points are saved checkpoints; epoch 0 is untrained. Probabilities are not calibrated certainty.
How a window becomes a representation
A GRU reads one nine-value sensor sample at a time. Its 128 hidden units form a changing memory of the window. The same learned weights are reused at all 128 time steps; a unit is a numerical feature, not a named activity or a physical sensor.
Inspect every fifth sensor sample, with the first and final states retained. The controls snap to these 27 saved times; no states are interpolated.
Reading the network: How a GRU carries information through time · Hidden units and hidden states · From a representation to class scores · Scores, softmax and confidence · Input scaling and batch normalization
Arrows carry the entire 128-value hidden state to the next step. Each box is the same GRU with the same weights, applied at a different time—not a separate layer. Dashed arrows skip steps in this drawing only.
Selected sensor sample
Source units before training-only standardization. The nine standardized values enter the GRU together.
Selected hidden state
One tile per hidden unit, numbered 0–127. Click a tile to follow that unit through time. Every unit can combine information from all nine inputs and the preceding state; there is no sensor-to-unit pairing.
After the final sample
h₁₂₈ · 128 responses
↓ learned weighted sums + biases
6 activity scores → softmax
The prediction uses the final state even when inspecting an earlier sample. UMAP also uses final states, with its layout fixed at epoch 15.
Signals over the window
The cursor marks the selected sample. Click a trace to move to the nearest saved time.
Hidden-state history
Columns are 27 saved time samples; rows are hidden units. States are retained every five sensor samples (0.1 seconds), plus the final sample at 2.54 seconds. The last interval is shorter. Click the heatmap to select a unit and time. The color scale stays fixed at −1 to +1 across windows and checkpoints.
The time slider moves within one window; the checkpoint selector moves through training. Hidden states reset to zero before each window. Intermediate states are not separately trained to classify partial windows.
Recognizing activities in unseen participants
The network learns from 5,953 windows belonging to 17 people. Four different people supply 1,399 validation windows for model selection; the official nine test participants supply 2,947 windows for the final evaluation.
Accuracy is the fraction of windows classified correctly. Macro F1 gives each activity equal weight by averaging its precision–recall F1 score. The drop from validation to test shows that a strong result on four validation participants does not guarantee the same performance on other people. Overlapping windows from the same person are correlated; these are not thousands of independent participants.
Signals and model
UCI HAR records a waist-mounted smartphone at 50 Hz. Each provider-preprocessed window contains 128 samples (2.56 seconds), with 50% overlap. Nine inputs comprise total acceleration and body acceleration (x, y, z; g), and body angular velocity (x, y, z; rad/s). Signals shown here retain source units. The network receives values standardized using training-only channel means and standard deviations.
PyTorch supplies tensor computation, the GRU implementation, and automatic differentiation. This model has one unidirectional GRU with 128 hidden units and a linear six-class head: 54,150 trainable parameters. It is trained from random initialization, rather than fine-tuned from a pretrained model. A reset gate controls how the previous state enters a candidate update; an update gate blends that candidate with retained state. The final state is multiplied by learned classifier weights and added to biases to produce six scores.
Training and selection
Twenty epochs use cross-entropy loss, AdamW (learning rate 0.001, weight decay 0.0001), batches of 64, FP32 precision, and gradient-norm clipping at 1. There is no scheduler, augmentation, dropout, or early stopping. Seed: 20261028. Checkpoints are saved at epochs 0, 1, 2, 3, 5, 10, 15, and 20. Epoch 15 has the highest validation macro F1 among trained saved checkpoints; epoch 20 is the last training snapshot. Test evaluation follows model selection.
split by participant; fit normalization on training signals
initialize GRU(9 → 128) and linear classifier(128 → 6)
for each training batch:
start each window with hidden state = 0
for each of 128 sensor samples:
hidden = GRU(sample, previous hidden)
scores = linear(final hidden)
minimize cross-entropy against recorded activity
at saved checkpoints:
save model, validation scores and final hidden vectors
save hidden histories for 48 fixed validation windows
export every fifth time sample plus the final state
select checkpoint by validation macro F1; evaluate test once
fit UMAP to selected-model validation final states onlyVisualization and coverage
UMAP uses cosine distance, 15 neighbors, minimum distance 0.15, and random seed 42. Activity labels do not enter the fit. All 1,399 validation windows have signals and predictions at eight checkpoints. Detailed histories of 27 saved times × 128 units are available for 48 windows: two per activity per validation participant, sampled before training. These are saved observations, not newly computed explanations. Unit numbers can be followed through this run, but have no fixed semantic meaning across different models.
Baseline, resources and limits
The baseline is logistic regression on 36 window summaries: mean, standard deviation, minimum, and maximum for each input channel, with training-only feature scaling. It is not the dataset’s published 561-feature benchmark; the two models have no matched tuning search. This is one split and one training seed, with no causal attribution from hidden-state visualizations.
Training took 11.5 seconds for 20 epochs on an NVIDIA RTX 4050 Laptop GPU. Peak allocated CUDA tensor memory was about 183 MiB during training and 220 MiB during export. These omit driver/context memory; timing excludes download, data parsing, and baseline fitting.
Participant split and provenance
Train: 1, 5, 6, 7, 8, 11, 14, 16, 17, 19, 21, 23, 26, 27, 28, 29, 30. Validation: 3, 15, 22, 25. Test: 2, 4, 9, 10, 12, 13, 18, 20, 24. Window identifiers beginning “train” refer to the official source partition, including the internal validation subset.
Source DOI: 10.24432/C54S4K. Source archive hashes, split IDs, normalization, checkpoints and verification are retained with the pilot. UCI’s current license statement and the historical bundled README differ; public redistribution requires resolving that discrepancy.