Francisco Castillo commited on
Commit
4444c16
1 Parent(s): fa41cf5
Files changed (1) hide show
  1. fashion_mnist_label_drift.py +19 -22
fashion_mnist_label_drift.py CHANGED
@@ -17,11 +17,7 @@
17
 
18
 
19
  import csv
20
- import json
21
- import os
22
-
23
  import datasets
24
- from datasets.tasks import TextClassification
25
 
26
 
27
 
@@ -132,6 +128,7 @@ class FashionMNISTLabelDrift(datasets.GeneratorBasedBuilder):
132
  # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
133
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
134
  extracted_paths = dl_manager.download_and_extract(_URLS)
 
135
  return [
136
  datasets.SplitGenerator(
137
  name=datasets.Split("training"),
@@ -176,21 +173,21 @@ class FashionMNISTLabelDrift(datasets.GeneratorBasedBuilder):
176
  "ner_tags":ner_tags_list,
177
  }
178
 
179
- def _generate_examples(self, filepath, split):
180
- """This function returns the examples in the raw form."""
181
- # Images
182
- with open(filepath[0], "rb") as f:
183
- # First 16 bytes contain some metadata
184
- _ = f.read(4)
185
- size = struct.unpack(">I", f.read(4))[0]
186
- _ = f.read(8)
187
- images = np.frombuffer(f.read(), dtype=np.uint8).reshape(size, 28, 28)
188
-
189
- # Labels
190
- with open(filepath[1], "rb") as f:
191
- # First 8 bytes contain some metadata
192
- _ = f.read(8)
193
- labels = np.frombuffer(f.read(), dtype=np.uint8)
194
-
195
- for idx in range(size):
196
- yield idx, {"image": images[idx], "label": int(labels[idx])}
 
17
 
18
 
19
  import csv
 
 
 
20
  import datasets
 
21
 
22
 
23
 
 
128
  # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
129
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
130
  extracted_paths = dl_manager.download_and_extract(_URLS)
131
+ print(extracted_paths)
132
  return [
133
  datasets.SplitGenerator(
134
  name=datasets.Split("training"),
 
173
  "ner_tags":ner_tags_list,
174
  }
175
 
176
+ #def _generate_examples(self, filepath, split):
177
+ # """This function returns the examples in the raw form."""
178
+ # # Images
179
+ # with open(filepath[0], "rb") as f:
180
+ # # First 16 bytes contain some metadata
181
+ # _ = f.read(4)
182
+ # size = struct.unpack(">I", f.read(4))[0]
183
+ # _ = f.read(8)
184
+ # images = np.frombuffer(f.read(), dtype=np.uint8).reshape(size, 28, 28)
185
+
186
+ # # Labels
187
+ # with open(filepath[1], "rb") as f:
188
+ # # First 8 bytes contain some metadata
189
+ # _ = f.read(8)
190
+ # labels = np.frombuffer(f.read(), dtype=np.uint8)
191
+
192
+ # for idx in range(size):
193
+ # yield idx, {"image": images[idx], "label": int(labels[idx])}