Implementations of inverse contrastive loss from Learning Invariant Representations using Inverse Contrastive Loss. The model architecture used on the ADNI dataset in the paper is also included along with PyTorch and Tensorflow implementations of the loss function.
$ pip install ic-lossimport torch
from ic_loss.losses import icl, icl_tf # icl - pytorch, icl_tf - tensorflow
from ic_loss.models import ADNIResNet # ADNIResNet - pytroch model used in the paper
model = ADNIResNet()
x = torch.randn([1, 1, 512, 512])
logits, latent = model(x)
loss = icl(latent, c) # c - extraneous attribute