# HobbitLong/SupContrast

PyTorch implementation of "Supervised Contrastive Learning"  (and SimCLR incidentally)

Repository: https://github.com/HobbitLong/SupContrast
Canonical: https://ross.abutalabs.com/products/supcontrast
Language: Python
License: BSD-2-Clause
License Family: permissive
Last push: 2023-12-26T21:20:36+00:00

## Health v2 (maintenance only)
Score: 32/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 0, release rhythm 35, longevity 100
- inputs: {"age_days": 2308, "days_push": 981, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3449, forks 553 (observed 2026-08-28T04:08:05.246346+00:00)

## What it is
A PyTorch reference implementation of the Supervised Contrastive Learning paper (SupCon loss) that also supports SimCLR when labels are omitted. It includes training scripts for CIFAR-10/100 and ImageNet experiments with ResNet architectures.

## Use cases
- implement supervised contrastive learning in pytorch
- train a simclr model on cifar
- compute supcon loss for representation learning
- reproduce supervised contrastive learning paper results
- learn contrastive loss implementation details
- pretrain image encoders with contrastive objectives

## When to choose
- you need a reference implementation of the SupCon loss in PyTorch
- you want to reproduce the paper's CIFAR or ImageNet results
- you want a simple loss module that falls back to SimCLR without labels

## When to avoid
- you need a maintained production training framework
- you want a general-purpose self-supervised library with many methods
- you need support for frameworks other than PyTorch

## Facets
- artifact type: library
- maturity: maintenance
- function: machine-learning, deep-learning
- domain: machine-learning, deep-learning, computer-vision
- platform: python
- tags: pytorch, contrastive-learning, simclr, supervised-contrastive-loss, self-supervised-learning, representation-learning, cifar, research-code, gpu

## Member repositories
- HobbitLong/SupContrast (main) score 32

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:08:05.246346+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:37:35.431199+00:00, confidence not recorded.
  - readme: https://github.com/HobbitLong/SupContrast (fetched 2026-08-28T04:08:05.246346+00:00, sha e52765e4baf1)
- Data as of 2026-08-30T08:39:29.467469+00:00.
