qualia2.data package

Submodules

qualia2.data.basic module

class qualia2.data.basic.Spiral(num_class=3, num_data=100)[source]

Bases: qualia2.data.dataset.Dataset

Spiral Dataset

Args:

num_class (int): number of classes num_data (int): number of data for each classes

Shape:
  • data: [num_class*num_data, 2]

  • label: [num_class*num_data, num_class]

show(label=None)[source]
show_decision_boundary(model)[source]
class qualia2.data.basic.SwissRoll(num_class=5, num_data=2000)[source]

Bases: qualia2.data.dataset.Dataset

Swiss roll dataset

Args:

num_class (int): number of classes num_data (int): number of data for each classes

Note:

num_data % num_class == 0

show(label=None)[source]

qualia2.data.cifar module

class qualia2.data.cifar.CIFAR10(train=True, transforms=Compose(transforms=[ToTensor(), Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])]), target_transforms=None)[source]

Bases: qualia2.data.dataset.Dataset

CIFAR10 Dataset

Args:

normalize (bool): If true, the intensity value of a specific pixel in a specific image will be rescaled from [0, 255] to [0, 1]. Default: True flatten (bool): If true, data will have a shape of [N, 3*32*32]. Default: False

Shape:
  • data: [N, 3, 32, 32]

prepare()[source]
show(row=10, col=10)[source]
state_dict()[source]
class qualia2.data.cifar.CIFAR100(train=True, transforms=Compose(transforms=[ToTensor(), Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])]), target_transforms=None, label_type='fine')[source]

Bases: qualia2.data.dataset.Dataset

CIFAR100 Dataset

Args:

normalize (bool): If true, the intensity value of a specific pixel in a specific image will be rescaled from [0, 255] to [0, 1]. Default: True flatten (bool): If true, data will have a shape of [N, 3*32*32]. Default: False label_type (str): “fine” label (the class to which it belongs) or “coarse” label (the superclass to which it belongs)

Shape:
  • data: [N, 3, 32, 32]

prepare()[source]
show(row=10, col=10)[source]
state_dict()[source]

qualia2.data.dataloader module

class qualia2.data.dataloader.DataLoader(dataset, batch_size=1, shuffle=False)[source]

Bases: object

provides an iterable over the given dataset.

show(*args, **kwargs)[source]

plot the samples of the dataset

qualia2.data.dataset module

class qualia2.data.dataset.Dataset(train=True, transforms=None, target_transforms=None)[source]

Bases: object

prepare()[source]
show()[source]
state_dict()[source]
static to_one_hot(label, num_class)[source]

convert the label to one hot representation Args:

label (ndarray | Tensor): label data num_class (int): number of the class in a dataset

static to_vector(label)[source]

convert the label to vector representation Args:

label (ndarray | Tensor): label data

qualia2.data.emnist module

class qualia2.data.emnist.EMNIST(train=True, transforms=Compose(transforms=[ToTensor(), Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])]), target_transforms=None)[source]

Bases: qualia2.data.dataset.Dataset

EMNIST Dataset

Args:

normalize (bool): If true, the intensity value of a specific pixel in a specific image will be rescaled from [0, 255] to [0, 1]. Default: True flatten (bool): If true, data will have a shape of [N, 28*28]. Default: False

Shape:
  • data: [N, 1, 28, 28]

prepare()[source]
show(row=10, col=10)[source]
state_dict()[source]

qualia2.data.fashion_mnist module

class qualia2.data.fashion_mnist.FashionMNIST(train=True, transforms=Compose(transforms=[ToTensor(), Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])]), target_transforms=None)[source]

Bases: qualia2.data.dataset.Dataset

FashionMNIST Dataset

Args:

normalize (bool): If true, the intensity value of a specific pixel in a specific image will be rescaled from [0, 255] to [0, 1]. Default: True flatten (bool): If true, data will have a shape of [N, 28*28]. Default: False

Shape:
  • data: [N, 1, 28, 28]

prepare()[source]
show(row=10, col=10)[source]
state_dict()[source]

qualia2.data.fimlp module

class qualia2.data.fimlp.FIMLP(train=True, transforms=Compose(transforms=[ToTensor(), Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])]), target_transforms=None)[source]

Bases: qualia2.data.dataset.Dataset

FIMLP Dataset

Args:

normalize (bool): If true, the intensity value of a specific pixel in a specific image will be rescaled from [0, 255] to [0, 1]. Default: True flatten (bool): If true, data will have a shape of [N, 96*96]. Default: False

Shape:
  • data: [N, 1, 96, 96] if flatten [N, 96*96]

Label:

Only x and y of the eyes center, nose tip and mouth center will be used as a label by default due to its small number of missing values. Landmarks Missing left_eye_center_x 10 left_eye_center_y 10 right_eye_center_x 13 right_eye_center_y 13 # left_eye_inner_corner_x 4778 # left_eye_inner_corner_y 4778 # left_eye_outer_corner_x 4782 # left_eye_outer_corner_y 4782 # right_eye_inner_corner_x 4781 # right_eye_inner_corner_y 4781 # right_eye_outer_corner_x 4781 # right_eye_outer_corner_y 4781 # left_eyebrow_inner_end_x 4779 # left_eyebrow_inner_end_y 4779 # left_eyebrow_outer_end_x 4824 # left_eyebrow_outer_end_y 4824 # right_eyebrow_inner_end_x 4779 # right_eyebrow_inner_end_y 4779 # right_eyebrow_outer_end_x 4813 # right_eyebrow_outer_end_y 4813 nose_tip_x 0 nose_tip_y 0 # mouth_left_corner_x 4780 # mouth_left_corner_y 4780 # mouth_right_corner_x 4779 # mouth_right_corner_y 4779 # mouth_center_top_lip_x 4774 # mouth_center_top_lip_y 4774 mouth_center_bottom_lip_x 33 mouth_center_bottom_lip_y 33

prepare()[source]
show(row=5, col=5)[source]

qualia2.data.kuzushi_mnist module

class qualia2.data.kuzushi_mnist.Kuzushi49(train=True, transforms=Compose(transforms=[ToTensor(), Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])]), target_transforms=None)[source]

Bases: qualia2.data.dataset.Dataset

Kuzushi49 Dataset

Args:

normalize (bool): If true, the intensity value of a specific pixel in a specific image will be rescaled from [0, 255] to [0, 1]. Default: True flatten (bool): If true, data will have a shape of [N, 28*28]. Default: False

Shape:
  • data: [N, 1, 28, 28]

prepare()[source]
show(row=10, col=10)[source]
state_dict()[source]
class qualia2.data.kuzushi_mnist.KuzushiMNIST(train=True, transforms=Compose(transforms=[ToTensor(), Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])]), target_transforms=None)[source]

Bases: qualia2.data.dataset.Dataset

KuzushiMNIST Dataset

Args:

normalize (bool): If true, the intensity value of a specific pixel in a specific image will be rescaled from [0, 255] to [0, 1]. Default: True flatten (bool): If true, data will have a shape of [N, 28*28]. Default: False

Shape:
  • data: [N, 1, 28, 28] if flatten [N, 28*28]

prepare()[source]
show(row=10, col=10)[source]
state_dict()[source]

qualia2.data.mnist module

class qualia2.data.mnist.MNIST(train=True, transforms=Compose(transforms=[ToTensor(), Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])]), target_transforms=None)[source]

Bases: qualia2.data.dataset.Dataset

MNIST Dataset

Args:

normalize (bool): If true, the intensity value of a specific pixel in a specific image will be rescaled from [0, 255] to [0, 1]. Default: True flatten (bool): If true, data will have a shape of [N, 28*28]. Default: False

Shape:
  • data: [N, 1, 28, 28]

prepare()[source]
show(row=10, col=10)[source]
state_dict()[source]

qualia2.data.stl10 module

class qualia2.data.stl10.STL10(train=True, transforms=Compose(transforms=[ToTensor(), Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])]), target_transforms=None)[source]

Bases: qualia2.data.dataset.Dataset

STL10 Dataset

Args:

normalize (bool): If true, the intensity value of a specific pixel in a specific image will be rescaled from [0, 255] to [0, 1]. Default: True flatten (bool): If true, data will have a shape of [N, 28*28]. Default: False

Shape:
  • data: [N, 3, 96, 96] if flatten [N, 3*96*96]

prepare()[source]
show(row=5, col=5)[source]
state_dict()[source]

qualia2.data.transforms module

class qualia2.data.transforms.CenterCrop(size)[source]

Bases: object

Crops the given PIL Image at the center. Args:

size (int): Desired output size of the crop.

class qualia2.data.transforms.Compose(transforms=[])[source]

Bases: object

Composes several transforms together. Args:

transforms (list): list of transforms

append(transform)[source]
class qualia2.data.transforms.Flatten[source]

Bases: object

Flatten a image

class qualia2.data.transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])[source]

Bases: object

Normalize a tensor image with mean and standard deviation.

class qualia2.data.transforms.Resize(size, interpolation=2)[source]

Bases: object

Resize the input PIL Image to the given size. Args:

size (int): Desired output size. (size * height / width, size) interpolation (int): Desired interpolation. Default is PIL.Image.BILINEAR

class qualia2.data.transforms.ToPIL[source]

Bases: object

Convert Tensor to PIL Image.

class qualia2.data.transforms.ToTensor[source]

Bases: object

Convert a PIL Image or numpy array to Tensor.

Module contents