MCPcopy Create free account
hub / github.com/DeepGraphLearning/graphvite / MNIST

Class MNIST

python/graphvite/dataset.py:758–793  ·  view source on GitHub ↗

MNIST dataset for visualization. Splits: train_image_data, train_label_data, test_image_data, test_label_data, image_data, label_data

Source from the content-addressed store, hash-verified

756
757
758class MNIST(Dataset):
759 """
760 MNIST dataset for visualization.
761
762 Splits:
763 train_image_data, train_label_data, test_image_data, test_label_data, image_data, label_data
764 """
765 def __init__(self):
766 super(MNIST, self).__init__(
767 "mnist",
768 urls={
769 "train_image_data": "http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz",
770 "train_label_data": "http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz",
771 "test_image_data": "http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz",
772 "test_label_data": "http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz",
773 "image_data": [], # depends on `train_image_data` & `test_image_data`
774 "label_data": [] # depends on `train_label_data` & `test_label_data`
775 }
776 )
777
778 def train_image_data_preprocess(self, raw_file, save_file):
779 images = np.fromfile(raw_file, dtype=np.uint8)
780 return images[16:].reshape(-1, 28*28)
781
782 def train_label_data_preprocess(self, raw_file, save_file):
783 labels = np.fromfile(raw_file, dtype=np.uint8)
784 return labels[8:]
785
786 test_image_data_preprocess = train_image_data_preprocess
787 test_label_data_preprocess = train_label_data_preprocess
788
789 def image_data_preprocess(self, save_file):
790 return np.concatenate([self.train_image_data, self.test_image_data])
791
792 def label_data_preprocess(self, save_file):
793 return np.concatenate([self.train_label_data, self.test_label_data])
794
795
796class CIFAR10(Dataset):

Callers 1

dataset.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected