Skip to main content

Self-adjusting Dice Loss

This is an unofficial PyTorch implementation of the Dice Loss for Data-imbalanced NLP Tasks paper.

Usage

Installation

pip install sadice

Text classification example

import torch
from sadice import SelfAdjDiceLoss

criterion = SelfAdjDiceLoss()
# (batch_size, num_classes)
logits = torch.rand(128, 10, requires_grad=True)
targets = torch.randint(0, 10, size=(128, ))

loss = criterion(logits, targets)
loss.backward()

NER example

import torch
from sadice import SelfAdjDiceLoss

criterion = SelfAdjDiceLoss(reduction="none")
# (batch_size, num_tokens, num_classes)
logits = torch.rand(128, 40, 10, requires_grad=True)
targets = torch.randint(0, 10, size=(128, 40))

loss = criterion(logits.view(-1, 10), targets.view(-1))
loss = loss.reshape(-1, 40).mean(-1).mean()
loss.backward()

Metadata

Release files for sadice 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sadice 0.1.3
File Size Uploaded Provenance Actions
sadice-0.1.3.tar.gz 6.4 kB Without provenance Details for sadice-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sadice 0.1.3
File Interpreter ABI Platform Actions
sadice-0.1.3-py3-none-any.whl Python 3 none any Details for sadice-0.1.3-py3-none-any.whl

Total release size: 13.0 kB

Release files / sadice-0.1.3.tar.gz

Download URL sadice-0.1.3.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8ee273d72dedc0ca984402c415f766c8f72a5fc4a69167d09d2c0fe396ddc70c
BLAKE2b-256 checksum
How to use checksums
123f2775ef9dbc1813d9967fd25ba84da83519ba007ecefc13cbad324f30d56a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.9 CPython/3.7.9 Darwin/19.6.0

Release files / sadice-0.1.3-py3-none-any.whl

Download URL sadice-0.1.3-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
271b9f25e117d81836c13852837c9fb155589d407fb345b9fd7e87bb14d3ff43
BLAKE2b-256 checksum
How to use checksums
9fedf566e4791f0c1eb1a2edc459d571ee93a4579fada122f4028c69d4d8f131
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.9 CPython/3.7.9 Darwin/19.6.0

Security for sadice 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page