braincog.datasets package

Subpackages

Submodules

braincog.datasets.CUB2002011 module

class braincog.datasets.CUB2002011.CUB2002011(root, train=True, transform=None, target_transform=None, download=False)

基类:VisionDataset

CUB-200-2011 Dataset. :param root: Root directory of the dataset. :type root: string :param train: If True, creates dataset from training set, otherwise

creates from test set.

参数
  • transform (callable, optional) – A function/transform that takes in an PIL image and returns a transformed version. E.g, transforms.RandomCrop

  • target_transform (callable, optional) – A function/transform that takes in the target and transforms it.

  • download (bool, optional) – If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again.

base_folder = 'CUB_200_2011/images'
file_id = '1hbzc_P1FuxMkcabkgn9ZKinBwW683j45'
filename = 'CUB_200_2011.tgz'
tgz_md5 = '97eceeb196236b17998738112f37df78'

braincog.datasets.StanfordDogs module

class braincog.datasets.StanfordDogs.StanfordDogs(root, train=True, transform=None, target_transform=None, download=False)

基类:VisionDataset

Stanford Dogs Dataset. :param root: Root directory of the dataset. :type root: string :param train: If True, creates dataset from training set, otherwise

creates from test set.

参数
  • transform (callable, optional) – A function/transform that takes in an PIL image and returns a transformed version. E.g, transforms.RandomCrop

  • target_transform (callable, optional) – A function/transform that takes in the target and transforms it.

  • download (bool, optional) – If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again.

download()
download_url_prefix = 'http://vision.stanford.edu/aditya86/ImageNetDogs'
load_split()
stats()

braincog.datasets.TinyImageNet module

class braincog.datasets.TinyImageNet.TinyImageNet(root, split='train', transform=None, target_transform=None, download=False)

基类:VisionDataset

tiny-imageNet Dataset. :param root: Root directory of the dataset. :type root: string :param split: The dataset split, supports train, or val. :type split: string, optional :param transform: A function/transform that takes in an PIL image

and returns a transformed version. E.g, transforms.RandomCrop

参数
  • target_transform (callable, optional) – A function/transform that takes in the target and transforms it.

  • download (bool, optional) – If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again.

base_folder = 'tiny-imagenet-200/'
filename = 'tiny-imagenet-200.zip'
md5 = '90528d7ca1a48142e341f4ef8d21d0de'
url = 'http://cs231n.stanford.edu/tiny-imagenet-200.zip'
braincog.datasets.TinyImageNet.find_classes(class_file)
braincog.datasets.TinyImageNet.make_dataset(root, base_folder, dirname, class_to_idx)

braincog.datasets.cut_mix module

class braincog.datasets.cut_mix.CutMix(dataset, num_class, num_mix=1, beta=1.0, prob=1.0, indices=None, noise=0.0, vis=False, **kwargs)

基类:Dataset

class braincog.datasets.cut_mix.EventMix(dataset, num_class, num_mix=1, beta=1.0, prob=1.0, indices=None, noise=0.1, vis=False, gaussian_n=None, **kwargs)

基类:Dataset

braincog.datasets.cut_mix.GMM_mask(size, rat, n=None)
braincog.datasets.cut_mix.GMM_mask_clip(size, rat)
class braincog.datasets.cut_mix.MixUp(dataset, num_class, num_mix=1, beta=1.0, prob=1.0, indices=None, noise=0.0, vis=False, **kwargs)

基类:Dataset

braincog.datasets.cut_mix.calc_lam(x1, x2, bbt1, bbt2, bbx1, bbx2, bby1, bby2)
braincog.datasets.cut_mix.calc_masked_lam(x1, x2, mask)
braincog.datasets.cut_mix.calc_masked_lam_with_difference(x1, x2, mix, kernel_size=3)
braincog.datasets.cut_mix.event_difference(x1, x2, kernel_size=3)
braincog.datasets.cut_mix.onehot(size, target)
braincog.datasets.cut_mix.rand_bbox(size, rat)
braincog.datasets.cut_mix.rand_bbox_st(size, rat)
braincog.datasets.cut_mix.rand_bbox_time(size, rat)
braincog.datasets.cut_mix.spatio_mask(size, rat)
braincog.datasets.cut_mix.st_mask(size, rat)
braincog.datasets.cut_mix.temporal_mask(size, rat)

braincog.datasets.datasets module

class braincog.datasets.datasets.MNISTData(data_path: str, batch_size: int, train_trans: Optional[Sequence[Module]] = None, test_trans: Optional[Sequence[Module]] = None, pin_memory: bool = True, drop_last: bool = True, shuffle: bool = True)

基类:object

Load MNIST datesets.

get_data_loaders()
get_standard_data()
braincog.datasets.datasets.build_dataset(is_train, img_size, dataset, path, same_da=False)

构建带有增强策略的数据集 :param is_train: 是否训练集 :param img_size: 输出图像尺寸 :param dataset: 数据集名称 :param path: 数据集路径 :param same_da: 为训练集使用测试集的增广方法 :return: 增强后的数据集

braincog.datasets.datasets.build_transform(is_train, img_size)

构建数据增强, 适用于static data :param is_train: 是否训练集 :param img_size: 输出的图像尺寸 :return: 数据增强策略

braincog.datasets.datasets.get_CUB2002011_data(batch_size, num_workers=8, same_da=False, *args, **kwargs)
braincog.datasets.datasets.get_FGVCAircraft_data(batch_size, num_workers=8, same_da=False, *args, **kwargs)
braincog.datasets.datasets.get_Flowers102_data(batch_size, num_workers=8, same_da=False, *args, **kwargs)
braincog.datasets.datasets.get_NCALTECH101_data(batch_size, step, **kwargs)

获取NCaltech101数据 http://journal.frontiersin.org/Article/10.3389/fnins.2015.00437/abstract :param batch_size: batch size :param step: 仿真步长 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.datasets.get_NCARS_data(batch_size, step, **kwargs)

获取N-Cars数据 https://ieeexplore.ieee.org/document/8578284/ :param batch_size: batch size :param step: 仿真步长 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.datasets.get_StanfordCars_data(batch_size, num_workers=8, same_da=False, *args, **kwargs)
braincog.datasets.datasets.get_StanfordDogs_data(batch_size, num_workers=8, same_da=False, *args, **kwargs)
braincog.datasets.datasets.get_TinyImageNet_data(batch_size, num_workers=8, same_da=False, *args, **kwargs)
braincog.datasets.datasets.get_cifar100_data(batch_size, num_workers=8, same_data=False, *args, **kwargs)

获取CIFAR100数据 https://www.cs.toronto.edu/~kriz/cifar.html :param batch_size: batch size :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.datasets.get_cifar10_data(batch_size, num_workers=8, same_da=False, **kwargs)
获取CIFAR10数据

https://www.cs.toronto.edu/~kriz/cifar.html

参数
  • batch_size – batch size

  • kwargs

返回

(train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.datasets.get_dvsc10_data(batch_size, step, **kwargs)

获取DVS CIFAR10数据 http://journal.frontiersin.org/article/10.3389/fnins.2017.00309/full :param batch_size: batch size :param step: 仿真步长 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.datasets.get_dvsg_data(batch_size, step, **kwargs)

获取DVS Gesture数据 DOI: 10.1109/CVPR.2017.781 :param batch_size: batch size :param step: 仿真步长 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.datasets.get_esimnet_data(batch_size, step, **kwargs)

获取ES imagenet数据 DOI: 10.3389/fnins.2021.726582 :param batch_size: batch size :param step: 仿真步长,固定为8 :param reconstruct: 重构则时间步为1, 否则为8 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn) :note: 没有自动下载, 下载及md5请参考spikingjelly, sampler默认为DistributedSampler

braincog.datasets.datasets.get_fashion_data(batch_size, num_workers=8, same_da=False, **kwargs)

获取fashion MNIST数据 http://arxiv.org/abs/1708.07747 :param batch_size: batch size :param same_da: 为训练集使用测试集的增广方法 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.datasets.get_imnet_data(args, _logger, data_config, num_aug_splits, **kwargs)

获取ImageNet数据集 http://arxiv.org/abs/1409.0575 :param args: 其他的参数 :param _logger: 日志路径 :param data_config: 增强策略 :param num_aug_splits: 不同增强策略的数量 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.datasets.get_mnist_data(batch_size, num_workers=8, same_da=False, **kwargs)

获取MNIST数据 http://data.pymvpa.org/datasets/mnist/ :param batch_size: batch size :param same_da: 为训练集使用测试集的增广方法 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.datasets.get_nomni_data(batch_size, train_portion=1.0, **kwargs)

获取N-Omniglot数据 :param batch_size:batch的大小 :param data_mode:一共full nkks pair三种模式 :param frames_num:一个样本帧的个数 :param data_type:event frequency两种模式

braincog.datasets.datasets.unpack_mix_param(args)

braincog.datasets.gen_input_signal module

braincog.datasets.rand_aug module

braincog.datasets.rand_aug.CutoutAbs(x, v)
braincog.datasets.rand_aug.CutoutTemporal(x, v)
braincog.datasets.rand_aug.GaussianBlur(x, v)
braincog.datasets.rand_aug.Identity(x, v)
class braincog.datasets.rand_aug.RandAugment(n, m)

基类:object

braincog.datasets.rand_aug.Rotate(x, v)
braincog.datasets.rand_aug.SaltAndPepperNoise(x, v)
braincog.datasets.rand_aug.ShearX(x, v)
braincog.datasets.rand_aug.ShearY(x, v)
braincog.datasets.rand_aug.SpatioShift(x, v)
braincog.datasets.rand_aug.TemporalShift(x, v)
braincog.datasets.rand_aug.TranslateX(x, v)
braincog.datasets.rand_aug.TranslateY(x, v)
braincog.datasets.rand_aug.drop(x, v)

braincog.datasets.utils module

braincog.datasets.utils.dvs_channel_check_expend(x)

检查是否存在DVS数据缺失, N-Car中有的数据会缺少一个通道 :param x: 输入的tensor :return: 补全之后的数据

braincog.datasets.utils.rescale(x, factor=None)

数据放缩函数 :param x: 输入的tensor :param factor: 缩放因子 :return: 缩放后的数据

Module contents

braincog.datasets.build_dataset(is_train, img_size, dataset, path, same_da=False)

构建带有增强策略的数据集 :param is_train: 是否训练集 :param img_size: 输出图像尺寸 :param dataset: 数据集名称 :param path: 数据集路径 :param same_da: 为训练集使用测试集的增广方法 :return: 增强后的数据集

braincog.datasets.build_transform(is_train, img_size)

构建数据增强, 适用于static data :param is_train: 是否训练集 :param img_size: 输出的图像尺寸 :return: 数据增强策略

braincog.datasets.dvs_channel_check_expend(x)

检查是否存在DVS数据缺失, N-Car中有的数据会缺少一个通道 :param x: 输入的tensor :return: 补全之后的数据

braincog.datasets.get_NCALTECH101_data(batch_size, step, **kwargs)

获取NCaltech101数据 http://journal.frontiersin.org/Article/10.3389/fnins.2015.00437/abstract :param batch_size: batch size :param step: 仿真步长 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.get_NCARS_data(batch_size, step, **kwargs)

获取N-Cars数据 https://ieeexplore.ieee.org/document/8578284/ :param batch_size: batch size :param step: 仿真步长 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.get_cifar100_data(batch_size, num_workers=8, same_data=False, *args, **kwargs)

获取CIFAR100数据 https://www.cs.toronto.edu/~kriz/cifar.html :param batch_size: batch size :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.get_cifar10_data(batch_size, num_workers=8, same_da=False, **kwargs)
获取CIFAR10数据

https://www.cs.toronto.edu/~kriz/cifar.html

参数
  • batch_size – batch size

  • kwargs

返回

(train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.get_dvsc10_data(batch_size, step, **kwargs)

获取DVS CIFAR10数据 http://journal.frontiersin.org/article/10.3389/fnins.2017.00309/full :param batch_size: batch size :param step: 仿真步长 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.get_dvsg_data(batch_size, step, **kwargs)

获取DVS Gesture数据 DOI: 10.1109/CVPR.2017.781 :param batch_size: batch size :param step: 仿真步长 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.get_fashion_data(batch_size, num_workers=8, same_da=False, **kwargs)

获取fashion MNIST数据 http://arxiv.org/abs/1708.07747 :param batch_size: batch size :param same_da: 为训练集使用测试集的增广方法 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.get_imnet_data(args, _logger, data_config, num_aug_splits, **kwargs)

获取ImageNet数据集 http://arxiv.org/abs/1409.0575 :param args: 其他的参数 :param _logger: 日志路径 :param data_config: 增强策略 :param num_aug_splits: 不同增强策略的数量 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.get_mnist_data(batch_size, num_workers=8, same_da=False, **kwargs)

获取MNIST数据 http://data.pymvpa.org/datasets/mnist/ :param batch_size: batch size :param same_da: 为训练集使用测试集的增广方法 :param kwargs: :return: (train loader, test loader, mixup_active, mixup_fn)

braincog.datasets.get_nomni_data(batch_size, train_portion=1.0, **kwargs)

获取N-Omniglot数据 :param batch_size:batch的大小 :param data_mode:一共full nkks pair三种模式 :param frames_num:一个样本帧的个数 :param data_type:event frequency两种模式

braincog.datasets.rescale(x, factor=None)

数据放缩函数 :param x: 输入的tensor :param factor: 缩放因子 :return: 缩放后的数据