Datasets:
parquet-converter
commited on
Commit
•
1589602
1
Parent(s):
93ed774
Update parquet files
Browse files
README.md
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
---
|
2 |
-
license: cc-by-sa-3.0
|
3 |
-
task_categories:
|
4 |
-
- image-classification
|
5 |
-
language:
|
6 |
-
- en
|
7 |
-
pretty_name: mnist_ambigous
|
8 |
-
size_categories:
|
9 |
-
- 10K<n<100K
|
10 |
-
source_datasets:
|
11 |
-
- extended|mnist
|
12 |
-
annotations_creators:
|
13 |
-
- machine-generated
|
14 |
-
---
|
15 |
-
|
16 |
-
|
17 |
-
# Mnist-Ambiguous
|
18 |
-
|
19 |
-
This dataset contains mnist-like images, but with an unclear ground truth. For each image, there are two classes which could be considered true.
|
20 |
-
Robust and uncertainty-aware DNNs should thus detect and flag these issues.
|
21 |
-
|
22 |
-
### Features
|
23 |
-
Same as mnist, the supervised dataset has an `image` (28x28 int array) and a `label` (int).
|
24 |
-
|
25 |
-
Additionally, the following features are exposed for your convenience:
|
26 |
-
|
27 |
-
- `text_label` (str): A textual representation of the probabilistic label, e.g. `p(Pullover)=0.54, p(Shirt)=0.46`
|
28 |
-
- `p_label` (list of floats): Ground-Truth probabilities for each class (two nonzero values for our ambiguous images)
|
29 |
-
- `is_ambiguous` (bool): Flag indicating if this is one of our ambiguous images (see 'splits' below)
|
30 |
-
|
31 |
-
### Splits
|
32 |
-
We provide four splits:
|
33 |
-
|
34 |
-
- `test`: 10'000 ambiguous images
|
35 |
-
- `train`: 10'000 ambiguous images - adding ambiguous images to the training set makes sure test-time ambiguous images are in-distribution.
|
36 |
-
- `test_mixed`: 20'000 images, consisting of the (shuffled) concatenation of our ambiguous `test` test and the nominal mnist test set by LeCun et. al.,
|
37 |
-
- `train_mixed`: 70'000 images, consisting
|
38 |
-
|
39 |
-
For research targeting explicitly aleatoric uncertainty, we recommend training the model using `train_mixed`.
|
40 |
-
Otherwise, our `test` set will lead to both epistemic and aleatoric uncertainty.
|
41 |
-
Note that in related literature, these 'mixed' splits are sometimes denoted as *dirty* splits.
|
42 |
-
|
43 |
-
### Assessment and Validity
|
44 |
-
For a brief discussion of the strength and weaknesses of this dataset,
|
45 |
-
including a quantitative comparison to the (only) other ambiguous datasets available in the literature, we refer to our paper.
|
46 |
-
|
47 |
-
### Paper
|
48 |
-
Pre-print here: [https://arxiv.org/abs/2207.10495](https://arxiv.org/abs/2207.10495)
|
49 |
-
|
50 |
-
Citation:
|
51 |
-
```
|
52 |
-
@misc{https://doi.org/10.48550/arxiv.2207.10495,
|
53 |
-
doi = {10.48550/ARXIV.2207.10495},
|
54 |
-
url = {https://arxiv.org/abs/2207.10495},
|
55 |
-
author = {Weiss, Michael and Gómez, André García and Tonella, Paolo},
|
56 |
-
title = {A Forgotten Danger in DNN Supervision Testing: Generating and Detecting True Ambiguity},
|
57 |
-
publisher = {arXiv},
|
58 |
-
year = {2022}
|
59 |
-
}
|
60 |
-
```
|
61 |
-
|
62 |
-
### License
|
63 |
-
As this is a derivative work of mnist, which is CC-BY-SA 3.0 licensed, our dataset is released using the same license.
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mninst_ambiguous/mnist_ambiguous-test.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4061497cf40e6b581602b7fb1c21fca989947f5d9a18156e8036ff41ff336e79
|
3 |
+
size 5155508
|
mninst_ambiguous/mnist_ambiguous-test_mixed.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:928fa7013af245ffcb38b9c2fbc128e7d38b44609c4fef291a2b86566d267495
|
3 |
+
size 7635346
|
mninst_ambiguous/mnist_ambiguous-train.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4061497cf40e6b581602b7fb1c21fca989947f5d9a18156e8036ff41ff336e79
|
3 |
+
size 5155508
|
mninst_ambiguous/mnist_ambiguous-train_mixed.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:12b84bc4305b19528948851a4a9d9671251917cfd2c9316006ec53df4e5d6940
|
3 |
+
size 19850097
|
mnist_ambiguous.py
DELETED
@@ -1,164 +0,0 @@
|
|
1 |
-
"""An ambiguous mnist data set"""
|
2 |
-
|
3 |
-
import csv
|
4 |
-
|
5 |
-
import datasets
|
6 |
-
import numpy as np
|
7 |
-
from datasets.tasks import ImageClassification
|
8 |
-
|
9 |
-
_CITATION = """\
|
10 |
-
@misc{https://doi.org/10.48550/arxiv.2207.10495,
|
11 |
-
doi = {10.48550/ARXIV.2207.10495},
|
12 |
-
url = {https://arxiv.org/abs/2207.10495},
|
13 |
-
author = {Weiss, Michael and Gómez, André García and Tonella, Paolo},
|
14 |
-
title = {A Forgotten Danger in DNN Supervision Testing: Generating and Detecting True Ambiguity},
|
15 |
-
publisher = {arXiv},
|
16 |
-
year = {2022}
|
17 |
-
}
|
18 |
-
"""
|
19 |
-
|
20 |
-
_DESCRIPTION = """\
|
21 |
-
The images were created such that they have an unclear ground truth,
|
22 |
-
i.e., such that they are similar to multiple - but not all - of the datasets classes.
|
23 |
-
Robust and uncertainty-aware models should be able to detect and flag these ambiguous images.
|
24 |
-
As such, the dataset should be merged / mixed with the original dataset and we
|
25 |
-
provide such 'mixed' splits for convenience. Please refer to the dataset card for details.
|
26 |
-
"""
|
27 |
-
|
28 |
-
_HOMEPAGE = "https://github.com/testingautomated-usi/ambiguous-datasets"
|
29 |
-
_LICENSE = "https://raw.githubusercontent.com/testingautomated-usi/ambiguous-datasets/main/LICENSE"
|
30 |
-
|
31 |
-
_VERSION = "0.1.0"
|
32 |
-
_URL = f"https://github.com/testingautomated-usi/ambiguous-datasets/releases/download/v{_VERSION}/"
|
33 |
-
|
34 |
-
_URLS = {
|
35 |
-
"train": "mnist-test.csv",
|
36 |
-
"test": "mnist-test.csv",
|
37 |
-
}
|
38 |
-
|
39 |
-
_NAMES = [
|
40 |
-
"T - shirt / top",
|
41 |
-
"Trouser",
|
42 |
-
"Pullover",
|
43 |
-
"Dress",
|
44 |
-
"Coat",
|
45 |
-
"Sandal",
|
46 |
-
"Shirt",
|
47 |
-
"Sneaker",
|
48 |
-
"Bag",
|
49 |
-
"Ankle boot",
|
50 |
-
]
|
51 |
-
|
52 |
-
|
53 |
-
class MnistAmbiguous(datasets.GeneratorBasedBuilder):
|
54 |
-
"""An ambiguous mnist data set"""
|
55 |
-
|
56 |
-
BUILDER_CONFIGS = [
|
57 |
-
datasets.BuilderConfig(
|
58 |
-
name="mninst_ambiguous",
|
59 |
-
version=datasets.Version(_VERSION),
|
60 |
-
description=_DESCRIPTION,
|
61 |
-
)
|
62 |
-
]
|
63 |
-
|
64 |
-
def _info(self):
|
65 |
-
return datasets.DatasetInfo(
|
66 |
-
description=_DESCRIPTION,
|
67 |
-
features=datasets.Features(
|
68 |
-
{
|
69 |
-
"image": datasets.Image(),
|
70 |
-
"label": datasets.features.ClassLabel(names=_NAMES),
|
71 |
-
"text_label": datasets.Value("string"),
|
72 |
-
"p_label": datasets.Sequence(datasets.Value("float32"), length=10),
|
73 |
-
"is_ambiguous": datasets.Value("bool"),
|
74 |
-
}
|
75 |
-
),
|
76 |
-
supervised_keys=("image", "label"),
|
77 |
-
homepage=_HOMEPAGE,
|
78 |
-
citation=_CITATION,
|
79 |
-
task_templates=[ImageClassification(image_column="image", label_column="label")],
|
80 |
-
)
|
81 |
-
|
82 |
-
def _split_generators(self, dl_manager):
|
83 |
-
urls_to_download = {key: _URL + fname for key, fname in _URLS.items()}
|
84 |
-
downloaded_files = dl_manager.download(urls_to_download)
|
85 |
-
|
86 |
-
return [
|
87 |
-
datasets.SplitGenerator(
|
88 |
-
name=datasets.Split.TRAIN,
|
89 |
-
gen_kwargs={
|
90 |
-
"filepath": downloaded_files["train"],
|
91 |
-
"split": "train",
|
92 |
-
},
|
93 |
-
),
|
94 |
-
datasets.SplitGenerator(
|
95 |
-
name=datasets.Split.TEST,
|
96 |
-
gen_kwargs={
|
97 |
-
"filepath": downloaded_files["test"],
|
98 |
-
"split": "test",
|
99 |
-
},
|
100 |
-
),
|
101 |
-
datasets.SplitGenerator(
|
102 |
-
name="train_mixed",
|
103 |
-
gen_kwargs={
|
104 |
-
"filepath": downloaded_files["train"],
|
105 |
-
"split": "train_mixed",
|
106 |
-
},
|
107 |
-
),
|
108 |
-
datasets.SplitGenerator(
|
109 |
-
name="test_mixed",
|
110 |
-
gen_kwargs={
|
111 |
-
"filepath": downloaded_files["test"],
|
112 |
-
"split": "test_mixed",
|
113 |
-
},
|
114 |
-
),
|
115 |
-
]
|
116 |
-
|
117 |
-
def _generate_examples(self, filepath, split):
|
118 |
-
"""This function returns the examples in the raw form."""
|
119 |
-
|
120 |
-
def _gen_amb_images():
|
121 |
-
with open(filepath) as csvfile:
|
122 |
-
spamreader = csv.reader(csvfile, delimiter=',', quotechar='"')
|
123 |
-
for i, row in enumerate(spamreader):
|
124 |
-
if i == 0:
|
125 |
-
continue
|
126 |
-
|
127 |
-
det_label = int(row[7])
|
128 |
-
class_1, class_2 = int(row[3]), int(row[4])
|
129 |
-
p_1, p_2 = float(row[5]), float(row[6])
|
130 |
-
text_label = f"p({_NAMES[class_1]})={p_1:.2f}, p({_NAMES[class_2]})={p_2:.2f}"
|
131 |
-
|
132 |
-
p_label = [0.0] * 10
|
133 |
-
p_label[class_1] = p_1
|
134 |
-
p_label[class_2] = p_2
|
135 |
-
|
136 |
-
image = np.array(row[9:], dtype=np.uint8).reshape(28, 28)
|
137 |
-
|
138 |
-
yield i, {"image": image, "label": det_label,
|
139 |
-
"text_label": text_label, "p_label": p_label, "is_ambiguous": True}
|
140 |
-
|
141 |
-
if split == "test" or split == "train":
|
142 |
-
yield from _gen_amb_images()
|
143 |
-
|
144 |
-
elif split == "test_mixed" or split == "train_mixed":
|
145 |
-
|
146 |
-
nominal_samples = []
|
147 |
-
nom_split = "test" if split == "test_mixed" else "train"
|
148 |
-
nominal_dataset = datasets.load_dataset("mnist", split=nom_split)
|
149 |
-
for x in nominal_dataset:
|
150 |
-
nominal_samples.append({
|
151 |
-
"image": np.array(x["image"]),
|
152 |
-
"label": x["label"],
|
153 |
-
"text_label": f"p({_NAMES[x['label']]})=1",
|
154 |
-
"p_label": [1.0 if i == x["label"] else 0.0 for i in range(10)],
|
155 |
-
"is_ambiguous": False
|
156 |
-
})
|
157 |
-
|
158 |
-
ambiguous_samples = list([x for i, x in _gen_amb_images()])
|
159 |
-
all_samples = nominal_samples + ambiguous_samples
|
160 |
-
np.random.RandomState(42).shuffle(all_samples)
|
161 |
-
|
162 |
-
for i, x in enumerate(all_samples):
|
163 |
-
yield i, x
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|