LABEL NOISE#

This module provides functions to generate noisy labels.

The following types of noise are supported: - Symmetric noise: For each class, assign a random class as noisy target with probability –noise_rate. - Asymmetric noise: Apply asymmetric noise to the supported datasets (CIFAR-10, CIFAR-100).

The noisy labels can be cached to improve reproducibility. This can be disabled by setting –disable_noisy_labels_cache=1.

The code is based on: - Symmetric Cross Entropy for Robust Learning with Noisy Labels - Making Deep Neural Networks Robust to Label Noise: a Loss Correction Approach - Generalized Cross Entropy Loss for Training Deep Neural Networks with Noisy Labels <https://arxiv.org/pdf/1805.07836>`_

Functions#

datasets.utils.label_noise.build_noisy_labels(targets, args)[source]#

Generate noisy labels according to the noise type specified in the CLI arguments.

Parameters:
  • targets (ndarray) – array of true targets

  • args (Namespace) – CLI arguments

Returns:

Noisy targets

Return type:

ndarray

datasets.utils.label_noise.get_asymmetric_noise(targets, args)[source]#

Apply asymmetric noise to the supported datasets (CIFAR-10, CIFAR-100).

The function supports caching the noisy targets to improve reproducibility. This can be disabled by setting –disable_noisy_labels_cache=1.

Parameters:
  • targets (ndarray) – array of true targets

  • args (Namespace) – CLI arguments

Returns:

Noisy targets

Return type:

ndarray

datasets.utils.label_noise.get_cifar100_noise_matrix(size, noise_rate)[source]#

Compute the noise matrix for CIFAR-100 by flipping each class to the “next” class with probability ‘noise_rate’.

Parameters:
  • size (int) – number of classes in the superclass

  • noise_rate (float) – probability of flipping to the next class

Returns:

Noise matrix

Return type:

ndarray

datasets.utils.label_noise.get_symmetric_noise(targets, args)[source]#

For each class, assign a random class as noisy target with probability –noise_rate. Does not alter the targets but returns a copy of the targets array with noisy targets.

The function supports caching the noisy targets to improve reproducibility. This can be disabled by setting –disable_noisy_labels_cache=1.

Parameters:
  • targets (ndarray) – array of true targets

  • args (Namespace) – CLI arguments

Returns:

Noisy targets

Return type:

ndarray

datasets.utils.label_noise.multiclass_noisify(y, P)[source]#

Flip classes according to transition matrix P. It expects a number between 0 and the number of classes - 1.

Return type:

ndarray

datasets.utils.label_noise.noisify_cifar100_asymmetric(targets, args)[source]#

Apply asymmetric noisy to CIFAR-100 according to the noise rate. For each superclass, the mistakes are chosen among samples of the same superclass.

Reference: Making Deep Neural Networks Robust to Label Noise: a Loss Correction Approach

Return type:

ndarray

datasets.utils.label_noise.noisify_cifar10_asymmetric(targets, args)[source]#

Apply asymmetric noisy to CIFAR-10 according to the noise rate and the following mistakes: - automobile <- truck - bird -> airplane - cat <-> dog - deer -> horse

Reference: Making Deep Neural Networks Robust to Label Noise: a Loss Correction Approach

Return type:

ndarray