# CoinCheung/pytorch-loss

label-smooth, amsoftmax, partial-fc, focal-loss, triplet-loss, lovasz-softmax. Maybe useful

Repository: https://github.com/CoinCheung/pytorch-loss
Canonical: https://ross.abutalabs.com/products/pytorch-loss
Language: Python
License: MIT
License Family: permissive
Topics: pytorch, dice-loss, triplet-loss, amsoftmax, cuda, label-smoothing, focal-loss, mish, ema, lovasz-softmax, partial-fc
Last push: 2024-10-17T01:41:43+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": 2702, "days_push": 686, "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 2252, forks 372 (observed 2026-08-28T04:06:31.047119+00:00)

## What it is
A PyTorch library providing a collection of loss functions (focal loss, triplet loss, AMSoftmax, label-smooth CE, dice loss, lovasz-softmax, partial-Fc, etc.) plus utility ops like one-hot encoding, EMA, and custom activations. Some operators ship as CUDA extensions for faster, more memory-efficient execution.

## Use cases
- train image segmentation models with dice or lovasz loss
- apply focal loss for class imbalance in detection
- use triplet loss or AMSoftmax for face recognition metric learning
- add label smoothing to cross-entropy training
- speed up loss computation with fused CUDA kernels
- use EMA of model weights during training

## When to choose
- you need a broad set of ready-made PyTorch loss functions in one package
- you want CUDA-accelerated versions of losses for speed and memory efficiency
- you train face recognition or segmentation models and need margin-based or dice losses

## When to avoid
- you need losses for frameworks other than PyTorch
- you cannot compile CUDA extensions and only want pure-PyTorch ops (though V1/V2 versions exist)
- you want a maintained, extensively documented library with guarantees

## Facets
- artifact type: library
- maturity: active
- function: machine-learning, deep-learning, gpu-computing
- domain: machine-learning, deep-learning, computer-vision, image-processing
- platform: python, cross-platform
- tags: pytorch, loss-functions, cuda-extension, focal-loss, triplet-loss, amsoftmax, label-smoothing, dice-loss, lovasz-softmax, partial-fc, activation-functions, ema, gpu, linux

## Member repositories
- CoinCheung/pytorch-loss (main) score 32

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:31.047119+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-30T02:43:48.437501+00:00, confidence not recorded.
  - readme: https://github.com/CoinCheung/pytorch-loss (fetched 2026-08-28T04:06:31.047119+00:00, sha c529e6c1a3c8)
- Data as of 2026-08-30T08:39:29.467469+00:00.
