# cifar10_n

<br />

> [!WARNING]
> **Warning:** Manual download required. See instructions below.

- **Description**:

A re-labeled version of CIFAR-10 with real human annotation errors. For every
pair (image, label) in the original CIFAR-10 train set, it provides several
additional labels given by real human annotators.

- **Homepage** :
  <https://ucsc-real.soe.ucsc.edu:1995/Home.html/>

- **Source code** :
  [`tfds.image_classification.cifar10_n.Cifar10N`](https://github.com/tensorflow/datasets/tree/master/tensorflow_datasets/image_classification/cifar10_n/cifar10_n.py)

- **Versions**:

  - `1.0.0`: Initial release.
  - `1.0.1`: Fixed typo in `worse_label` key.
  - `1.0.2`: Fixed correspondence between annotations and images.
  - `1.0.3`: Fixed files in `MANUAL_DIR`.
  - **`1.0.4`** (default): Fixed loading of side information.
- **Download size** : `162.17 MiB`

- **Dataset size** : `147.91 MiB`

- **Manual download instructions** : This dataset requires you to
  download the source data manually into `download_config.manual_dir`
  (defaults to `~/tensorflow_datasets/downloads/manual/`):  

  Download 'side_info_cifar10N.csv', 'CIFAR-10_human_ordered.npy' and
  'image_order_c10.npy' from <https://github.com/UCSC-REAL/cifar-10-100n>

Then convert 'CIFAR-10_human_ordered.npy' into a CSV file
'CIFAR-10_human_annotations.csv'. This can be done with the following code:

    import numpy as np
    from tensorflow_datasets.core.utils.lazy_imports_utils import pandas as pd
    from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow as tf

    human_labels_np_path = '<local_path>/CIFAR-10_human_ordered.npy'
    human_labels_csv_path = '<local_path>/CIFAR-10_human_annotations.csv'

    with tf.io.gfile.GFile(human_labels_np_path, "rb") as f:
      human_annotations = np.load(f, allow_pickle=True)

    df = pd.DataFrame(human_annotations[()])

    with tf.io.gfile.GFile(human_labels_csv_path, "w") as f:
      df.to_csv(f, index=False)

- **Auto-cached**
  ([documentation](https://www.tensorflow.org/datasets/performances#auto-caching)):
  Yes

- **Splits**:

| Split | Examples |
|---|---|
| `'test'` | 10,000 |
| `'train'` | 50,000 |

- **Feature structure**:

    FeaturesDict({
        'aggre_label': ClassLabel(shape=(), dtype=int64, num_classes=10),
        'id': Text(shape=(), dtype=string),
        'image': Image(shape=(32, 32, 3), dtype=uint8),
        'label': ClassLabel(shape=(), dtype=int64, num_classes=10),
        'random_label1': ClassLabel(shape=(), dtype=int64, num_classes=10),
        'random_label2': ClassLabel(shape=(), dtype=int64, num_classes=10),
        'random_label3': ClassLabel(shape=(), dtype=int64, num_classes=10),
        'worker1_id': int64,
        'worker1_time': float32,
        'worker2_id': int64,
        'worker2_time': float32,
        'worker3_id': int64,
        'worker3_time': float32,
        'worse_label': ClassLabel(shape=(), dtype=int64, num_classes=10),
    })

- **Feature documentation**:

| Feature | Class | Shape | Dtype | Description |
|---|---|---|---|---|
|   | FeaturesDict |   |   |   |
| aggre_label | ClassLabel |   | int64 |   |
| id | Text |   | string |   |
| image | Image | (32, 32, 3) | uint8 |   |
| label | ClassLabel |   | int64 |   |
| random_label1 | ClassLabel |   | int64 |   |
| random_label2 | ClassLabel |   | int64 |   |
| random_label3 | ClassLabel |   | int64 |   |
| worker1_id | Tensor |   | int64 |   |
| worker1_time | Tensor |   | float32 |   |
| worker2_id | Tensor |   | int64 |   |
| worker2_time | Tensor |   | float32 |   |
| worker3_id | Tensor |   | int64 |   |
| worker3_time | Tensor |   | float32 |   |
| worse_label | ClassLabel |   | int64 |   |

- **Supervised keys** (See
  [`as_supervised` doc](https://www.tensorflow.org/datasets/api_docs/python/tfds/load#args)):
  `None`

- **Figure**
  ([tfds.show_examples](https://www.tensorflow.org/datasets/api_docs/python/tfds/visualization/show_examples)):

![Visualization](https://storage.googleapis.com/tfds-data/visualization/fig/cifar10_n-1.0.4.png)

- **Examples** ([tfds.as_dataframe](https://www.tensorflow.org/datasets/api_docs/python/tfds/as_dataframe)):

<button id="displaydataframe">Display examples...</button>

- **Citation**:

    @inproceedings{wei2022learning,
      title={Learning with Noisy Labels Revisited: A Study Using Real-World Human
      Annotations},
      author={Jiaheng Wei and Zhaowei Zhu and Hao Cheng and Tongliang Liu and Gang
      Niu and Yang Liu},
      booktitle={International Conference on Learning Representations},
      year={2022},
      url={https://openreview.net/forum?id=TBWA6PLJZQm}
    }