Before running the notebooks, make sure that the runtime type is set to "GPU", by going to the Runtime menu, and clicking on "Change runtime type".
Click "Open in playground" on the Colab header to interact with the notebook.
Notebook | Description | Colab Link |
---|---|---|
MNIST using TripletMarginLoss | Train with TripletMarginLoss, evaluate with AccuracyCalculator. | |
MNIST using SubCenterArcFaceLoss | Train with SubCenterArcFaceLoss, view outlier samples. | |
MoCo on CIFAR10 | Self-supervision using MoCo with CrossBatchMemory | |
Multiprocessing with DistributedDataParallel | An example using pytorch_metric_learning.utils.distributed |
The following notebooks are meant to show entire training/testing workflows. (If you want to use just a loss or miner in your own code, see the notebooks above.) They generally go through the following steps:
- initialize models, optimizers, and transforms
- creates train/validation splits
- initialize a loss, miner, sampler, trainer, and tester
- train the model, record accuracy, and plot the embedding space
Notebook | Description | Colab Link |
---|---|---|
MetricLossOnly | Use just a metric loss. | |
A scRNAseq Metric Embedding | An example using canonical single-cell RNAseq cell types. | |
TrainWithClassifier | Use a metric loss + classification loss and network. | |
CascadedEmbeddings | Use multiple sub-networks and mine their outputs. | |
DeepAdversarialMetricLearning | Use a generator to create hard negatives during training. | |
TwoStreamMetricLoss | For use with two-stream datasets, where anchors and positives/negatives come from different sources. | |
Inference | Use the inference module after you're done training. |