This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pytorch implementation of | |
# Latent Variables on Spheres for Autoencoders in High Dimensions | |
# https://arxiv.org/pdf/1912.10233.pdf | |
# if implementation is wrong, please comment this gist | |
# x is (N, latent_size) | |
x = x - x.sum(-1, keepdim=True) / x.shape[-1] | |
x = x / torch.sqrt( (x**2).sum(-1, keepdim=True) ) |