MoCo pretraining and linear probing for radio IQ data with a single dataset
(train_norm_030_preprocessed.h5) with two downstream tasks:
AoA (angles regression) and AMC (modulation classification).
Contents
moco_experiment.pypretraining + finetuning pipeline (AoA + AMC).mtc_grid-search.pycrop-length grid search with KNN + silhouette metrics.moco/MoCo models and dataloaders.utils/training, finetune, and dataset helpers.models/shufflenet, mobilenet, resnet backbones.nbs/moco_multi_task_analysis.ipynbanalysis notebook.nbs/IQ_dataset_n_tasks.ipynbpreprocessing pipeline for dataset creation.configs/label_encoder_angles.yamlandconfigs/label_encoder_mods.yaml.
Data
- Place datasets under
data_h5py_files/. - Required files:
train_norm_030_preprocessed.h5,test_norm_030_preprocessed.h5. - Use
nbs/IQ_dataset_n_tasks.ipynbto generate the preprocessed HDF5 files.
Setup
python -m venv venv./venv/bin/pip install -r requirements.txt
Run
- Pretrain + finetune AoA and AMC:
python moco_experiment.py - Optional config override:
python moco_experiment.py -c path/to/config.yaml
Loss (Batch-Decoupled Queue)
When use_queue is enabled, we keep the original in-batch logits and append
queue negatives. This preserves the diagonal positives from the current batch
while adding extra negatives from the queue:
logits = [Q @ K^T | Q @ V^T] / T
Q: [N, C] (queries), K: [M, C] (in-batch keys), V: [C, K] (queue)
labels = arange(M) # positives are the diagonal in the first M columns
loss = CE(logits, labels)
Example (no DDP): N = M = 4, K = 8 → logits is [4, 12],
labels = [0, 1, 2, 3]. Each row has 1 positive (diagonal),
N-1 in-batch negatives, and K queue negatives.
Grid Search
- Example:
python mtc_grid-search.py --dataset-path ./data_h5py_files --train-file train_norm_030_preprocessed.h5 --test-file test_norm_030_preprocessed.h5 --task aoa
Notes
- Only
shufflenet,mobilenet, andresnet18backbones are supported in this project.