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

Function get_mnist

nlp_class3/bilstm_mnist.py:25–41  ·  view source on GitHub ↗
(limit=None)

Source from the content-addressed store, hash-verified

23
24
25def get_mnist(limit=None):
26 if not os.path.exists('../large_files'):
27 print("You must create a folder called large_files adjacent to the class folder first.")
28 if not os.path.exists('../large_files/train.csv'):
29 print("Looks like you haven't downloaded the data or it's not in the right spot.")
30 print("Please get train.csv from https://www.kaggle.com/c/digit-recognizer")
31 print("and place it in the large_files folder.")
32
33 print("Reading in and transforming data...")
34 df = pd.read_csv('../large_files/train.csv')
35 data = df.values
36 np.random.shuffle(data)
37 X = data[:, 1:].reshape(-1, 28, 28) / 255.0 # data is from 0..255
38 Y = data[:, 0]
39 if limit is not None:
40 X, Y = X[:limit], Y[:limit]
41 return X, Y
42
43
44

Callers 1

bilstm_mnist.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected