MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / read_data_sets

Function read_data_sets

tensorflow/input_data.py:118–147  ·  view source on GitHub ↗
(train_dir, fake_data=False, one_hot=False)

Source from the content-addressed store, hash-verified

116 end = self._index_in_epoch
117 return self._images[start:end], self._labels[start:end]
118def read_data_sets(train_dir, fake_data=False, one_hot=False):
119 class DataSets(object):
120 pass
121 data_sets = DataSets()
122 if fake_data:
123 data_sets.train = DataSet([], [], fake_data=True)
124 data_sets.validation = DataSet([], [], fake_data=True)
125 data_sets.test = DataSet([], [], fake_data=True)
126 return data_sets
127 TRAIN_IMAGES = 'train-images-idx3-ubyte.gz'
128 TRAIN_LABELS = 'train-labels-idx1-ubyte.gz'
129 TEST_IMAGES = 't10k-images-idx3-ubyte.gz'
130 TEST_LABELS = 't10k-labels-idx1-ubyte.gz'
131 VALIDATION_SIZE = 5000
132 local_file = maybe_download(TRAIN_IMAGES, train_dir)
133 train_images = extract_images(local_file)
134 local_file = maybe_download(TRAIN_LABELS, train_dir)
135 train_labels = extract_labels(local_file, one_hot=one_hot)
136 local_file = maybe_download(TEST_IMAGES, train_dir)
137 test_images = extract_images(local_file)
138 local_file = maybe_download(TEST_LABELS, train_dir)
139 test_labels = extract_labels(local_file, one_hot=one_hot)
140 validation_images = train_images[:VALIDATION_SIZE]
141 validation_labels = train_labels[:VALIDATION_SIZE]
142 train_images = train_images[VALIDATION_SIZE:]
143 train_labels = train_labels[VALIDATION_SIZE:]
144 data_sets.train = DataSet(train_images, train_labels)
145 data_sets.validation = DataSet(validation_images, validation_labels)
146 data_sets.test = DataSet(test_images, test_labels)
147 return data_sets

Callers

nothing calls this directly

Calls 5

DataSetsClass · 0.85
DataSetClass · 0.85
maybe_downloadFunction · 0.85
extract_imagesFunction · 0.85
extract_labelsFunction · 0.85

Tested by

no test coverage detected