pytorch / pytorch/vision

Enable custom samplers for imbalanced datasets

Open
#8,093 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

module: datasets new feature
Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Description

🚀 The feature

For each classification datasets with balanced distribution on the classes (MNIST, CIFAR-N, etc...), it would be very useful to provide a standard dataset for the imbalanced version of the dataset. For a dataset with $n$ classes, define the imbalance factor $a\in [0,1]$, then the proportion of class $i$ is typically be proportional to $a^{i/(n-1)}$, we need to normalize so that the proportions sums to $1$. For $a=1$ this is uniform and the smaller the imbalance coefficient the more imbalanced the dataset is.

I am not sure if torch vision should provide with the datasets or provide a data loader that imbalance the dataset.

Motivation, pitch

Many papers are published on the problem of training on an imbalanced dataset and testing on a balanced dataset, for instance see this. As far as I know, there is no systematic way of generating such data sets for people using Pytorch. Here are few very similar implementations that are not fully satisfying :

Such datasets seems to exist on TensorFlow, for instance section 3 of the readme of this repo provides with links to download tfrecord datasets.

I feels like it could be a very nice feature of torchvision to either contain such datasets or be able to craft them easily.

Alternatives

No response

Additional context

No response

cc @pmeier

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the referenced implementations in cao_cifar.py and ImbalanceCIFAR.py, then determine whether the requested capability belongs in datasets or a data loader. Define the public API and the expected class proportions, including the uniform a=1 case, before identifying tests and a concrete completion criterion.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data, machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.