Example #1
0
 def test_dataset_onehot(self):
     Xs, Ys = dsu.cifar10_load()
     ds = dsu.Dataset(
         Xs=Xs, ys=Ys, split=[0.8, 0.1, 0.1], one_hot=True, n_classes=10)
     X_i, Y_i = next(ds.train.next_batch())
     assert (X_i.shape == (100, 32, 32, 3))
     assert (Y_i.shape == (100, 10))
Example #2
0
def CIFAR10(flatten=True, split=[1.0, 0.0, 0.0]):
    """Returns the CIFAR10 dataset.

    Parameters
    ----------
    flatten : bool, optional
        Convert the 3 x 32 x 32 pixels to a single vector
    split : list, optional
        Description

    Returns
    -------
    cifar : Dataset
        Description
    """
    # plt.imshow(np.transpose(np.reshape(
    #   cifar.train.images[10], (3, 32, 32)), [1, 2, 0]))
    Xs, ys = cifar10_load()
    if flatten:
        Xs = Xs.reshape((Xs.shape[0], -1))
    return Dataset(Xs, ys, split=split)
Example #3
0
def CIFAR10(flatten=True, split=[1.0, 0.0, 0.0]):
    """Returns the CIFAR10 dataset.

    Parameters
    ----------
    flatten : bool, optional
        Convert the 3 x 32 x 32 pixels to a single vector
    split : list, optional
        Description

    Returns
    -------
    cifar : Dataset
        Description
    """
    # plt.imshow(np.transpose(np.reshape(
    #   cifar.train.images[10], (3, 32, 32)), [1, 2, 0]))
    Xs, ys = cifar10_load()
    if flatten:
        Xs = Xs.reshape((Xs.shape[0], -1))
    return Dataset(Xs, ys, split=split)
Example #4
0
 def test_draw_train_dataset(self):
     Xs, ys = dsu.cifar10_load()
     Xs = Xs[:100, ...].reshape((100, 3072))
     ys = ys[:100]
     ds = dsu.Dataset(Xs, ys, split=(0.5, 0.25, 0.25))
     draw.train_dataset(n_epochs=1, batch_size=25, ds=ds, A=32, B=32, C=3)
Example #5
0
 def test_dataset_split_batch_generator(self):
     Xs, Ys = dsu.cifar10_load()
     ds = dsu.Dataset(Xs=Xs, ys=Ys, split=[0.8, 0.1, 0.1], one_hot=False)
     X_i, Y_i = next(ds.train.next_batch())
     assert (X_i.shape == (100, 32, 32, 3))
     assert (Y_i.shape == (100,))
Example #6
0
 def test_dataset_split(self):
     Xs, Ys = dsu.cifar10_load()
     ds = dsu.Dataset(Xs=Xs, ys=Ys, split=[0.8, 0.1, 0.1], one_hot=False)
     assert (ds.train.images.shape == (40000, 32, 32, 3))
     assert (ds.valid.images.shape == (5000, 32, 32, 3))
     assert (ds.test.images.shape == (5000, 32, 32, 3))
Example #7
0
 def test_dataset(self):
     Xs, Ys = dsu.cifar10_load()
     ds = dsu.Dataset(Xs=Xs, ys=Ys, split=[0.8, 0.1, 0.1], one_hot=False)
     assert (ds.X.shape == (50000, 32, 32, 3))
     assert (ds.Y.shape == (50000,))
Example #8
0
 def test_cifar_loads(self):
     Xs, Ys = dsu.cifar10_load()
     assert (Xs.shape == (50000, 32, 32, 3))
     assert (Ys.shape == (50000,))
     assert (np.mean(Ys) == 4.5)
     assert (np.mean(Xs) == 120.70756512369792)
Example #9
0
 def test_draw_train_dataset(self):
     Xs, ys = dsu.cifar10_load()
     Xs = Xs[:100, ...].reshape((100, 3072))
     ys = ys[:100]
     ds = dsu.Dataset(Xs, ys, split=(0.5, 0.25, 0.25))
     draw.train_dataset(n_epochs=1, batch_size=25, ds=ds, A=32, B=32, C=3)