batchflow.opensets

MNIST

class MNIST(*args, bar=False, preloaded=None, train_test=True, **kwargs)[source]

Bases: batchflow.opensets.base.ImagesOpenset

MNIST dataset

Examples

# download MNIST data, split into train/test and create dataset instances
mnist = MNIST()
# iterate over the dataset
for batch in mnist.train.gen_batch(BATCH_SIZE, shuffle=True, n_epochs=2):
    # do something with a batch

# download MNIST data and show progress bar
mnist = MNIST(bar=True)
ALL_URLS = ['http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz', 'http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz', 'http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz', 'http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz']
TEST_IMAGES_URL = 'http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz'
TEST_LABELS_URL = 'http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz'
TRAIN_IMAGES_URL = 'http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz'
TRAIN_LABELS_URL = 'http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz'
download(url, content, path=None)[source]

Load data from the web site

num_classes = 10

CIFAR10

class CIFAR10(*args, bar=False, preloaded=None, train_test=True, **kwargs)[source]

Bases: batchflow.opensets.cifar.BaseCIFAR

CIFAR10 dataset

Examples

# download CIFAR data, split into train/test and create dataset instances
cifar = CIFAR10()

# iterate over the dataset
for batch in cifar.train.gen_batch(BATCH_SIZE, shuffle=True, n_epochs=2):
    # do something with a batch
LABELS_KEY = b'labels'
SOURCE_URL = 'https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz'
TEST_NAME_ID = 'test_batch'
TRAIN_NAME_ID = 'data_batch'
num_classes = 10

CIFAR100

class CIFAR100(*args, bar=False, preloaded=None, train_test=True, **kwargs)[source]

Bases: batchflow.opensets.cifar.BaseCIFAR

CIFAR100 dataset

Examples

# download CIFAR data, split into train/test and create dataset instances
cifar = CIFAR100()

# iterate over the dataset
for batch in cifar.train.gen_batch(BATCH_SIZE, shuffle=True, n_epochs=5):
    # do something with a batch
LABELS_KEY = b'fine_labels'
SOURCE_URL = 'https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz'
TEST_NAME_ID = 'test'
TRAIN_NAME_ID = 'train'
num_classes = 100