def load_mnist(dataset, path):
if dataset is "<STR_LIT>":<EOL><INDENT>fname_img = os.path.join(path, "<STR_LIT>")<EOL>fname_lbl = os.path.join(path, "<STR_LIT>")<EOL><DEDENT>elif dataset is "<STR_LIT>":<EOL><INDENT>fname_img = os.path.join(path, "<STR_LIT>")<EOL>fname_lbl = os.path.join(path, "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>with open(fname_lbl, "<STR_LIT:rb>") as flbl:<EOL><INDENT>magic, num = struct.unpack("<STR_LIT>", flbl.read(<NUM_LIT:8>))<EOL>labels = np.fromfile(flbl, dtype=np.int8)<EOL><DEDENT>with open(fname_img, "<STR_LIT:rb>") as fimg:<EOL><INDENT>magic, num, rows, cols = struct.unpack("<STR_LIT>", fimg.read(<NUM_LIT:16>))<EOL>images = np.multiply(<EOL>np.fromfile(fimg, dtype=np.uint8).reshape(len(labels), rows*cols),<EOL><NUM_LIT:1.0> / <NUM_LIT>)<EOL><DEDENT>get_instance = lambda idx: (labels[idx], images[idx].reshape(<NUM_LIT:1>, <NUM_LIT>, <NUM_LIT>))<EOL>size_reset = lambda x: x.reshape(<NUM_LIT:1>, <NUM_LIT>, <NUM_LIT>)<EOL>return list(map(size_reset, images))<EOL>
wget -O - http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz | gunzip > train-images-idx3-ubyte
wget -O - http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz | gunzip > train-labels-idx1-ubyte
wget -O - http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz | gunzip > t10k-images-idx3-ubyte
wget -O - http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz | gunzip > t10k-labels-idx1-ubyte