Beispiel #1
0
 def sample(self, B, N, K, **kwargs):
     dataset = self.get_MiniImagenet(train=False)
     loader = get_random_data_loader(
             self.get_MiniImagenet(False),
             B, N, K, 1, TEST_NUM_PER_CLASS, **kwargs)
             # transform=self.transform, **kwargs)
     return next(iter(loader))
Beispiel #2
0
 def get_train_loader(self):
     return get_random_data_loader(self.get_ImageNet32(),
                                   self.B,
                                   self.N,
                                   self.K,
                                   self.num_steps,
                                   TRAIN_NUM_PER_CLASS,
                                   classes=range(TRAIN_NUM_CLASSES))
Beispiel #3
0
 def get_train_loader(self):
     classes = range(TRAIN_NUM_CLASSES) if self.novel else None
     return get_random_data_loader(self.get_EMNIST(),
                                   self.B,
                                   self.N,
                                   self.K,
                                   self.num_steps,
                                   TRAIN_NUM_PER_CLASS,
                                   classes=classes)
Beispiel #4
0
 def get_train_loader(self):
     if self.phase == 1:
         classes = range(TRAIN_NUM_CLASSES // 2)
     else:
         classes = range(TRAIN_NUM_CLASSES)
     return get_random_data_loader(self.get_EMNIST(),
                                   self.B,
                                   self.N,
                                   self.K,
                                   self.num_steps,
                                   TRAIN_NUM_PER_CLASS,
                                   classes=classes)
Beispiel #5
0
 def sample(self, B, N, K, **kwargs):
     classes = range(TRAIN_NUM_CLASSES,
             TRAIN_NUM_CLASSES + TEST_NUM_CLASSES_NOVEL) \
                     if self.novel else None
     loader = get_random_data_loader(self.get_EMNIST(False),
                                     B,
                                     N,
                                     K,
                                     1,
                                     TEST_NUM_PER_CLASS,
                                     classes=classes,
                                     **kwargs)
     return next(iter(loader))
Beispiel #6
0
    def get_train_loader(self):
        dataset = EMNIST(os.path.join(datasets_path, 'emnist'),
                         split='balanced',
                         download=True,
                         train=True)

        def transform(x):
            return torch.bernoulli(x.unsqueeze(-3).float().div(255))

        classes = torch.arange(20) if self.novel else None
        return get_random_data_loader(dataset,
                                      self.B,
                                      self.N,
                                      self.K,
                                      self.num_steps,
                                      TRAIN_NUM_PER_CLASS,
                                      transform=transform,
                                      classes=classes)
Beispiel #7
0
    def sample(self, B, N, K, **kwargs):
        dataset = EMNIST(os.path.join(datasets_path, 'emnist'),
                         split='balanced',
                         download=True,
                         train=False)

        def transform(x):
            return torch.bernoulli(x.unsqueeze(-3).float().div(255))

        loader = get_random_data_loader(
            dataset,
            B,
            N,
            K,
            1,
            TEST_NUM_PER_CLASS,
            transform=transform,
            classes=(torch.arange(20, 47) if self.novel else None),
            transform=transform,
            **kwargs)
        return next(iter(loader))
Beispiel #8
0
 def get_train_loader(self):
     return get_random_data_loader(self.get_Kkanji(), self.B, self.N,
                                   self.K, self.num_steps,
                                   TRAIN_NUM_PER_CLASS)
Beispiel #9
0
 def sample(self, B, N, K, **kwargs):
     loader = get_random_data_loader(self.get_Kkanji(False), B, N, K, 1,
                                     TEST_NUM_PER_CLASS, **kwargs)
     return next(iter(loader))