Datasets:
Tasks:
Image Classification
Sub-tasks:
multi-class-classification
Languages:
English
Size:
10K<n<100K
License:
Francisco Castillo
commited on
Commit
•
99d8c14
1
Parent(s):
1ee7595
wip
Browse files- fashion_mnist_label_drift.py +19 -19
fashion_mnist_label_drift.py
CHANGED
@@ -159,7 +159,7 @@ class FashionMNISTLabelDrift(datasets.GeneratorBasedBuilder):
|
|
159 |
def _generate_examples(self, filepath):
|
160 |
# This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
161 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
162 |
-
|
163 |
with open(filepath) as file:
|
164 |
df = pd.read_hdf(file)
|
165 |
print(len(df))
|
@@ -178,21 +178,21 @@ class FashionMNISTLabelDrift(datasets.GeneratorBasedBuilder):
|
|
178 |
# "ner_tags":ner_tags_list,
|
179 |
# }
|
180 |
#
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
159 |
def _generate_examples(self, filepath):
|
160 |
# This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
161 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
162 |
+
print("CACA = ", filepath)
|
163 |
with open(filepath) as file:
|
164 |
df = pd.read_hdf(file)
|
165 |
print(len(df))
|
|
|
178 |
# "ner_tags":ner_tags_list,
|
179 |
# }
|
180 |
#
|
181 |
+
def _generate_examples(self, filepath, split):
|
182 |
+
"""This function returns the examples in the raw form."""
|
183 |
+
# Images
|
184 |
+
with open(filepath[0], "rb") as f:
|
185 |
+
# First 16 bytes contain some metadata
|
186 |
+
_ = f.read(4)
|
187 |
+
size = struct.unpack(">I", f.read(4))[0]
|
188 |
+
_ = f.read(8)
|
189 |
+
images = np.frombuffer(f.read(), dtype=np.uint8).reshape(size, 28, 28)
|
190 |
+
|
191 |
+
# Labels
|
192 |
+
with open(filepath[1], "rb") as f:
|
193 |
+
# First 8 bytes contain some metadata
|
194 |
+
_ = f.read(8)
|
195 |
+
labels = np.frombuffer(f.read(), dtype=np.uint8)
|
196 |
+
|
197 |
+
for idx in range(size):
|
198 |
+
yield idx, {"image": images[idx], "label": int(labels[idx])}
|