MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / read_data_sets

Function read_data_sets

neural_network/input_data.py:270–342  ·  view source on GitHub ↗
(
    train_dir,
    fake_data=False,
    one_hot=False,
    dtype=dtypes.float32,
    reshape=True,
    validation_size=5000,
    seed=None,
    source_url=DEFAULT_SOURCE_URL,
)

Source from the content-addressed store, hash-verified

268
269@deprecated(None, "Please use alternatives such as: tensorflow_datasets.load('mnist')")
270def read_data_sets(
271 train_dir,
272 fake_data=False,
273 one_hot=False,
274 dtype=dtypes.float32,
275 reshape=True,
276 validation_size=5000,
277 seed=None,
278 source_url=DEFAULT_SOURCE_URL,
279):
280 if fake_data:
281
282 def fake():
283 return _DataSet(
284 [], [], fake_data=True, one_hot=one_hot, dtype=dtype, seed=seed
285 )
286
287 train = fake()
288 validation = fake()
289 test = fake()
290 return _Datasets(train=train, validation=validation, test=test)
291
292 if not source_url: # empty string check
293 source_url = DEFAULT_SOURCE_URL
294
295 train_images_file = "train-images-idx3-ubyte.gz"
296 train_labels_file = "train-labels-idx1-ubyte.gz"
297 test_images_file = "t10k-images-idx3-ubyte.gz"
298 test_labels_file = "t10k-labels-idx1-ubyte.gz"
299
300 local_file = _maybe_download(
301 train_images_file, train_dir, source_url + train_images_file
302 )
303 with gfile.Open(local_file, "rb") as f:
304 train_images = _extract_images(f)
305
306 local_file = _maybe_download(
307 train_labels_file, train_dir, source_url + train_labels_file
308 )
309 with gfile.Open(local_file, "rb") as f:
310 train_labels = _extract_labels(f, one_hot=one_hot)
311
312 local_file = _maybe_download(
313 test_images_file, train_dir, source_url + test_images_file
314 )
315 with gfile.Open(local_file, "rb") as f:
316 test_images = _extract_images(f)
317
318 local_file = _maybe_download(
319 test_labels_file, train_dir, source_url + test_labels_file
320 )
321 with gfile.Open(local_file, "rb") as f:
322 test_labels = _extract_labels(f, one_hot=one_hot)
323
324 if not 0 <= validation_size <= len(train_images):
325 msg = (
326 "Validation size should be between 0 and "
327 f"{len(train_images)}. Received: {validation_size}."

Callers

nothing calls this directly

Calls 6

fakeFunction · 0.85
_DatasetsClass · 0.85
_maybe_downloadFunction · 0.85
_extract_imagesFunction · 0.85
_extract_labelsFunction · 0.85
_DataSetClass · 0.85

Tested by

no test coverage detected