This repository contains the codebase and implementation for my BSc thesis project (under Dr. Hao Tang) on self-supervised speech representation learning, following the Autoregressive Predictive Coding (APC) framework. The code explores how dynamic neural architectures originally proposed for ResNet affect the pretraining dynamics in the speech domain and how useful the learned representations remain for downstream speech tasks such as phone recognition, speaker identification and automatic speech recognition (ASR). In particular, this project explores Stochastic Depth networks (Huang et al., 2016) and Fractal Architectures (Zhang et al., 2020) on both LSTM and Transformer backbones.
Figure 1: Stochastic Depth Linear Decay as proposed by Huang et al. We use a hyperparameter with a linear decay schedule to preserve earlier layers with higher likelihood
Figure 2: Fractal Architecture proposed by Zhang et al. The macro-architecture uses convolution (transformer encoders in our work) blocks as units that get joined and pooled together before making a prediction
The project features several variations of LSTMs and Transformers to understand the impact of skip connections, stochastic depth and fractal structures on model generalization and training:
- Baseline UniLSTM: Standard unidirectional LSTM network. Note our networks need to be unidirectional to prevent information leakage from the future (required for APC training).
- LSTM with Skip Connections: Enforces direct residual information flow across layers. We use this as a baseline for the stochastic depth networks since they assume skip connections.
- Stochastic Depth LSTM: Applies the Stochastic Depth algorithm which randomly drops layers during training.
- Fractal LSTM: Fractal LSTM architecture with multiple branching columns and the drop-path regularization mechanism described in the paper.
- Transformer Encoder: Baseline transformer encoder with causal mask to prevent information leakage from the future.
- Fractal Transformer Encoder: Transformer encoder augmented with multiple branching columns and the drop-path regularization mechanism described in the paper.
The repository is modularized perfectly for scaling preprocessing, training, and downstream evaluations.
src/train.py: Pretrains the models using a self-supervised proxy task to predict future Mel features.src/train_probe.py: Trains a lightweight downstream model (i.e. Phone Probe) over frozen pretrained acoustic features.src/train_phone.py&predict_phone.py: Further downstream evaluation components for phone identification and sequence evaluation.
src/data.py&src/dataprep.py: Extensively handles the LibriSpeech Dataset iterations, shuffling, batching, and PyTorchDataLoader.src/kaldiark.py: Parses and reads standard Kaldi.arkaudio feature configurations.
src/models/lstm_models.py: Implementations of UniLSTM, UniLstmSkip, UniLstmStochastic, FractalLSTM, and downstream Probing LSTMs.src/models/transformer_models.py: Transformer sequence models tailored for APC sequences.
It is advised to set up your dataset properties (Mean/Variance files and scp indices) beforehand. See train.sh for an example of configuration passing:
# Example training loop across epochs
./train.sh path/to/experiment_directoryOr running the pipeline individually:
python src/train.py --config config.json --type "fractal-lstm" --layers 4 --hidden-size 512- Both Stochastic Depth and FractalNet architectures significantly reduce pre-training time with minimal accuracy loss
- Fractal models achieve the best trade-off, often matching or outperforming baselines
- Stochastic Depth improves efficiency but is more sensitive to hyperparameters
- Downstream performance remains largely unchanged despite faster training
Figure 3: Layer-wise phone-error rates for baseline, stochastic and fractal transformer encoder. We can see that the fractal transformer's performance is practically identical to the baseline, while stochastic depth performs slightly worse when including later layers
These results demonstrate that dynamic architectures can make self-supervised speech models more efficient without sacrificing useful representations.
For full context, empirical data, tables of results, and comprehensive ablation details regarding stochastic approaches, fractal layouts, and training parameters, please refer to the attached Thesis Report.pdf.