MCPcopy Create free account
hub / github.com/tflearn/tflearn / load_data

Function load_data

tflearn/datasets/cifar100.py:19–50  ·  view source on GitHub ↗
(dirname="cifar-100-python", one_hot=False)

Source from the content-addressed store, hash-verified

17
18
19def load_data(dirname="cifar-100-python", one_hot=False):
20 tarpath = maybe_download("cifar-100-python.tar.gz",
21 "http://www.cs.toronto.edu/~kriz/",
22 dirname)
23 X_train = []
24 Y_train = []
25
26 for i in ["train"]:
27 fpath = os.path.join(dirname, i)
28 data, labels = load_batch(fpath)
29 if i == "train":
30 X_train = data
31 Y_train = labels
32 else:
33 X_train = np.concatenate([X_train, data], axis=0)
34 Y_train = np.concatenate([Y_train, labels], axis=0)
35
36 fpath = os.path.join(dirname, 'test')
37 X_test, Y_test = load_batch(fpath)
38
39 X_train = np.dstack((X_train[:, :1024], X_train[:, 1024:2048],
40 X_train[:, 2048:])) / 255.
41 X_train = np.reshape(X_train, [-1, 32, 32, 3])
42 X_test = np.dstack((X_test[:, :1024], X_test[:, 1024:2048],
43 X_test[:, 2048:])) / 255.
44 X_test = np.reshape(X_test, [-1, 32, 32, 3])
45
46 if one_hot:
47 Y_train = to_categorical(Y_train, 100)
48 Y_test = to_categorical(Y_test, 100)
49
50 return (X_train, Y_train), (X_test, Y_test)
51
52
53def load_batch(fpath):

Callers

nothing calls this directly

Calls 3

to_categoricalFunction · 0.85
maybe_downloadFunction · 0.70
load_batchFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…