← Back to projects

Judo Clipper: Bidirectional LSTM

PythonPyTorchBidirectional LSTMGradient Clipping

A controlled experiment evaluating bidirectional recurrence for the LSTM throw-attempt classifier.

← Back to the Judo Clipper case study

Hypothesis

If the model architecture implements a bidirectional LSTM instead of a unidirectional LSTM, classification performance will improve.

Architecture and Configurations

The only difference between this experiment’s model architecture and the architecture used in the gradient-clipping experiment is that this model uses a bidirectional LSTM.

The bidirectional LSTM processes each sequence in both temporal directions. The final forward and backward hidden states are concatenated before being passed into the feed-forward classification head.

Everything else remains the same.

Architecture Configurations

HyperparameterValueDescription
LSTM Hidden Size128Number of features in each directional LSTM hidden state
LSTM Layers2Number of stacked recurrent layers
BidirectionalTrueProcesses each sequence in both temporal directions
Classifier Hidden Size64Intermediate projection before the final logit
Dropout Rate0.30Regularization applied within the model architecture

Training Configurations

ParameterValueDetails
Epochs50Total passes over the training data
Batch Size32Number of sequences per batch
Learning Rate0.001Base step size for the optimizer
Weight Decay0.0001L2 regularization to penalize large weights
Maximum Gradient Norm1.00Clips the total gradient norm to limit unusually large parameter updates

A maximum gradient norm of 1.0 was selected as a conventional initial value for recurrent neural network training. This value was kept fixed throughout the experiment.

Dataset for Experiment

The exact same dataset split that was used for the baseline and gradient-clipping experiments was used for this experiment.

i.e.

The proportions were:

SplitFraction (%)Manifest File / StrategyDetails / Purpose
Train80%splits/dataset_v1_stratified_seed_42.csv (Seed: 42)Model training and parameter updates
Validation10%splits/dataset_v1_stratified_seed_42.csv (Seed: 42)Hyperparameter tuning & threshold calibration
Test10%splits/dataset_v1_stratified_seed_42.csv (Seed: 42)Unbiased final performance evaluation

Given that the dataset contained 2,163 clips, the raw counts of the split were:

ClassTrainingValidationTestTotal
No attempt1,1121391391,390
Throw attempt6187778773
Overall total1,7302162172,163

Results

Results of Training

Diagram of Training Losses

Bidirectional LSTM training loss

Results of Evaluation Using the Validation Dataset Split

Evaluation Policy

The exact same evaluation policy that was used for the baseline and gradient-clipping experiments was used for this experiment.

i.e.

The model returns raw logits. During evaluation, sigmoid converts the logits into probabilities. A threshold of 0.50 was used as the initial reference, after which the validation threshold was selected by maximising attempt F1 according to the predefined tie-breaking policy. This selected a threshold of 0.34.

Results

The model was evaluated on the validation split using the checkpoint from the epoch with the lowest validation loss, which was epoch 22.

Model & Checkpoint Configuration

ParameterValue
Splitvalidation
Checkpointbest
Checkpoint Epoch22
Checkpoint Validation Loss0.3990
Classification Threshold0.3400 (validation-selected)

Dataset Counts

MetricCount
Total Samples216
Actual Attempts77
Actual No-Attempts139

Confusion Matrix

Breakdown
MetricCount
True Positives (TP)61
True Negatives (TN)119
False Positives (FP)20
False Negatives (FN)16
2×2 Matrix View
Predicted: AttemptPredicted: No-Attempt
Actual: Attempt61 (TP)16 (FN)
Actual: No-Attempt20 (FP)119 (TN)

Classification Metrics

Overall Performance
  • Accuracy: 0.8333 (83.33%)
  • Macro F1: 0.8204
Per-Class Metrics
ClassPrecisionRecallF1-Score
Attempt0.75310.79220.7722
No-Attempt0.88150.85610.8686

Comparison of Bidirectional Results vs Gradient-Clipped Unidirectional Model

MetricUnidirectional + Gradient ClippingBidirectional + Gradient ClippingChange
Best epoch4022N/A
Best validation loss0.42980.3990−0.0308
Selected threshold0.450.34−0.11
Accuracy0.82410.8333+0.0092
Attempt precision0.74680.7531+0.0063
Attempt recall0.76620.7922+0.0260
Attempt F10.75640.7722+0.0158
Macro F10.80940.8204+0.0110
TP5961+2
TN1191190
FP20200
FN1816−2

Analysis of Results

Changing from a unidirectional LSTM to a bidirectional LSTM improved validation performance.

The best validation loss decreased from 0.4298 to 0.3990, while attempt F1 increased from 0.7564 to 0.7722 and macro F1 increased from 0.8094 to 0.8204. Overall accuracy also increased from 0.8241 to 0.8333.

The bidirectional model correctly identified two additional attempt clips without increasing the number of false positives. This increased attempt recall from 0.7662 to 0.7922 while also producing a small increase in attempt precision.

These results support the hypothesis that processing the complete clip in both temporal directions can improve classification performance. However, the improvement was smaller than the improvement produced by introducing gradient clipping.

Analysis of Training Curve

The lowest validation loss occurred at epoch 22. After this point, the training and validation loss curves began to diverge, with training loss continuing to decrease while validation loss became more volatile.

This suggests that the model began to overfit the training data after its best epoch. The best-checkpoint policy handled this correctly by retaining the model state from epoch 22 rather than using the final model state from epoch 50.

The curve does not suggest that increasing the training budget beyond 50 epochs would improve validation performance.

Analysis of Evaluation on Validation Data

The bidirectional model produced 61 true positives and 20 false positives. Compared with the clipped unidirectional model, it correctly classified two additional attempt clips without incorrectly classifying any additional no-attempt clips.

This represents a favourable improvement because attempt recall increased while false-positive control was maintained. The bidirectional model therefore performed better than the clipped unidirectional model across best validation loss, attempt F1, macro F1, and overall accuracy.

Next Steps

Given that the bidirectional LSTM improved validation performance, bidirectionality will be retained alongside gradient clipping for subsequent experiments.

The bidirectional LSTM with gradient clipping is currently the strongest model based on validation performance.

If one final controlled experiment is conducted, it should test automatic positive-class weighting on this architecture while keeping bidirectionality, gradient clipping, the dataset split, and all other configurations unchanged. After this final experiment, the winning model will be selected using validation results before being evaluated once on the held-out test split.