CIFAR-10
1

CIFAR-10

The CIFAR-10 dataset consists of 60000 32x32 colour images in 10 classes, with 6000 images per class.

To train with an example CNN classification model:

mantra train cnn_example --dataset cifar10 --image-dim 32 32

Importing

To import this dataset to your project, run:

mantra import RJT1990/data/cifar10

Usage

Example usage in code:

from data.cifar10.data import CIFAR10 d = CIFAR10() print(d.X.__class__) ## <class 'numpy.ndarray'> print(d.y.__class__) ## <class 'numpy.ndarray'>

Data processing
import numpy as np from mantraml.data.Dataset import Dataset, cachedata from mantraml.data.ImageDataset import ImageDataset class CIFAR10(ImageDataset): # These class variables contain metadata on the Dataset data_name = 'CIFAR-10' data_tags = ['cifar', 'cifar10'] data_image = 'cifar.jpeg' files = ['cifar.tar.gz'] has_labels = True image_dim = (32, 32) # default - can override with command line @cachedata def y(self): """ This method extracts inputs from the data. The output should be an np.ndarray that can be processed by the model. Returns -------- np.ndarray - of data inputs (y vector) """ # if X isn't extracted, then extract it if self._X is None: self.X # calling will extract labels = [file_name.split('_')[1].split('.png')[0] for file_name in self.image_file_names] self.label_names = list(set(labels)) self.label_col_dict = dict(zip(self.label_names, range(len(self.label_names)))) numeric_labels = np.array([self.label_col_dict[name] for name in labels]) result = np.zeros((numeric_labels.size, 10), dtype=int) result[np.arange(numeric_labels.size), numeric_labels] = 1 return result
All files
Last Modified |
raw
18 September 2018 12:56 PM
__init__.py
17 September 2018 10:42 PM
cifar.jpeg
17 September 2018 10:42 PM
data.py
17 September 2018 10:42 PM
README.md
17 September 2018 10:42 PM