You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alignment and Uniformity Metrics for Representation Learning
This repository provides a PyTorch implementation of the alignment and uniformity metrics for unsupervised representation learning. These metrics are proposed in Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere.
# bsz : batch size (number of positive pairs)# d : latent dim# x : Tensor, shape=[bsz, d]# latents for one side of positive pairs# y : Tensor, shape=[bsz, d]# latents for the other side of positive pairsdefalign_loss(x, y, alpha=2):
return (x-y).norm(p=2, dim=1).pow(alpha).mean()
defuniform_loss(x, t=2):
returntorch.pdist(x, p=2).pow(2).mul(-t).exp().mean().log()
After import align_uniform, you can access them with
Tongzhou Wang, Phillip Isola. "Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere". International Conference on Machine Learning. 2020.
@inproceedings{wang2020hypersphere,
title={Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere},
author={Wang, Tongzhou and Isola, Phillip},
booktitle={International Conference on Machine Learning},
organization={PMLR},
pages={9929--9939},
year={2020}
}
Questions
For questions about the code provided in this repository, please open an GitHub issue.
For questions about the paper, please contact Tongzhou Wang (tongzhou _AT_ mit _DOT_ edu).
About
Open source code for paper "Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere" ICML 2020