Data & Machine LearningOctober 2026Status: Complete

Swimming Stroke Classification: Auditing a Video Model

Re-evaluating a CNN-RNN comparison and finding what the model actually learned

At a glance

Problem
My original comparison of video models reported a clear winner. I needed to know whether that result would hold under stricter evaluation.
My role
Built the original models, then refactored the project into a reproducible experiment framework and audited the results.
Key decision
Re-score the saved models with corrected code, then re-run every configuration under nested leave-one-video-out with 5 seeds, so the test video never influences training or model selection.
Result
The original metrics had evaluation bugs, and under strict evaluation all three temporal models land near chance: the frozen image features identify the source recording, not the stroke.
Proof
Original probabilities reproduced exactly (max difference ~1e-16)5 seeds per configurationSource recording identified with 100% accuracy from frozen features
Built with
Modeling
  • PyTorch
  • ResNet18
Sequence models
  • LSTM
  • GRU
  • BiGRU
Data
  • NumPy
Language
  • Python

In Practice

1 of 4

Context

The original project asked whether modeling movement over time helps classify swimming strokes from video, by comparing LSTM, GRU and bidirectional GRU models on the same image features. It reported a clear winner. Before relying on that result, I rebuilt the project as a reproducible experiment framework and checked whether the numbers held.

Does the original result survive a stricter, reproducible evaluation, and if not, what is the model actually learning?

The dataset has 411 clips from only three source recordings per stroke, so a model can score well by recognising the recording rather than the stroke. Evaluation code that mislabels classes or scores only part of the data makes the problem invisible. The challenge was to evaluate on what a model would actually face, recordings it has never seen, and to measure the result honestly.

Approach

Every frame is encoded once by a frozen ImageNet ResNet18 and cached; a small LSTM, GRU or BiGRU head then runs over 64 sampled frames, with flip and jittered-frame augmentation. Evaluation is nested leave-one-video-out: for each held-out recording, inner folds choose the epoch count without it, the model retrains on the other two and is scored on the held-out video. Every configuration runs over 5 seeds, reporting clip accuracy, macro F1, macro AUC and per-recording video accuracy.

Data sources

  • Public Swimming Instructional Videos

    Publicly available swimming videos segmented into 411 labeled clips of backstroke, breaststroke, butterfly and freestyle, drawn from three source recordings per stroke (twelve in total).

Solution

Original study

  1. Dataset. Built a labeled dataset of 411 clips across four strokes from public swimming videos, each represented as a 64-frame sequence.

  2. Three temporal models. Implemented CNN-LSTM, CNN-GRU and CNN-BiGRU models on a frozen ResNet18 backbone in PyTorch.

Audit

  1. Exact reproduction. Re-scored the original saved checkpoints with refactored code, reproducing the notebook's probabilities exactly.

  2. Evaluation bugs. Found that the original reports attached the wrong class names and that the reports and AUC covered only the last fold.

  3. Recording shortcut. Showed with a linear probe that frozen image features identify the source recording with 100% accuracy.

Re-run

  1. Strict re-run. Re-ran every model under nested leave-one-video-out with 5 seeds, plus a fixed 30-epoch budget and a normalization ablation.

  2. Reproducible runs. Made every run config-driven and reproducible, writing predictions, logs, per-seed metrics and figures for each experiment.

Architecture

A frozen, ImageNet-pretrained ResNet18 encodes each frame into a 512-dimensional feature vector. Because it never trains, features are computed once per clip and cached, for both the original frames and a horizontal flip.

A recurrent head (LSTM, GRU or bidirectional GRU) runs over 64 sampled frames, followed by max-pooling over time and a linear classifier.

Architecture: 64 sampled frames pass through a frozen ResNet18 into an LSTM, GRU or BiGRU head that predicts one of four strokes; evaluation holds out each recording, chooses epochs on the other two, then retrains and scores.
Hover to magnify · click to open full sizeTap to open full size

Components

  • Frozen ResNet18 feature extractor with cached features
  • LSTM, GRU and BiGRU temporal heads
  • Flip and jittered-frame augmentation
  • Nested leave-one-video-out evaluation
  • Config-driven experiment runner

Outcome

Re-scored correctly, the original models reach 0.47, 0.43 and 0.44 clip accuracy (LSTM, GRU, BiGRU), not the published figures. Under nested leave-one-video-out, all three land near chance at about 0.30 against 0.25; a fixed 30-epoch budget does a little better at 0.34–0.37. The temporal head barely matters (the three differ by less than one standard deviation, and a logistic regression on mean features scores about 0.40), because the frozen features encode which recording a clip came from: a model trained on one recording reaches near-zero training loss and then scores at chance on another.

Scope and limits

With three recordings per stroke, the data cannot support a reliable architecture comparison, so the finding is about the evaluation, not about which model is best. The original notebook still scores higher than the cached-feature runs, most likely because its BatchNorm layers stayed in training mode and adapted to swimming frames, along with color augmentation and a single seed.

Lessons Learned

  • Re-score before you trust a result. The original metrics looked reasonable and were wrong.

  • Evaluate on what the model will actually face. Holding out whole recordings exposed what random clip splits would have hidden.

  • When a model reaches near-perfect training loss and chance on held-out data, look for a shortcut. Here it was recording identity, not motion.

  • Class-level metrics reveal model behavior that overall accuracy alone can obscure.

  • With very little data, a training budget fixed in advance can beat noisy model selection.

What's next

  • Add more recordings per stroke, from different swimmers and cameras.
  • Fine-tune the backbone on swimming footage.
  • Use pose estimation or motion features that cannot encode recording identity.