Skip to main content

Implementation of inverse contrastive loss

Project description

Inverse Contrastive Loss

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.

Installation

$ pip install ic-loss

Usage

import 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 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ic_loss-1.0.1.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

ic_loss-1.0.1-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page