Пример #1
0
    def __init__(self, args, test_dataloader):
        self.args = args
        self.test_dataloader = test_dataloader

        self.bce_loss = nn.BCELoss()
        self.mse_loss = nn.MSELoss()
        self.ce_loss = nn.CrossEntropyLoss()

        self.sampler = sampler.AdversarySampler(self.args.budget)
 def __init__(self, args, test_dataloader):
     self.args = args
     self.test_dataloader = test_dataloader
     self.model_path = self.args.out_path
     self.bce_loss = nn.BCELoss()
     self.mse_loss = nn.MSELoss()
     self.ce_loss = nn.CrossEntropyLoss()
     # self.base_name = "discriminator_probs_"    # Only in the discriminator probabilties changes, no backward vae
     # self.base_name = "vae_back_dis_probs_"    # Vae backward done and discriminator probabilities only
     self.base_name = "m2_model"
     self.sampler = sampler.AdversarySampler(self.args.budget)
     if args.tensorboard is True:
         tb_path = os.path.join(args.out_path, 'tb_logs')
         if not os.path.exists(tb_path):
             os.mkdir(tb_path)
         self.writer_train = SummaryWriter(os.path.join(tb_path, 'summary_train'))
         self.writer_val = SummaryWriter(os.path.join(tb_path, 'summary_val'))
Пример #3
0
    def __init__(self, args, test_dataloader):
        self.args = args
        self.test_dataloader = test_dataloader

        self.bce_loss = nn.BCELoss()
        self.mse_loss = nn.MSELoss()
        self.ce_loss = nn.CrossEntropyLoss()

        self.sampling_method = args.sampling_method
        if self.sampling_method == "random":
            self.sampler = sampler.RandomSampler(self.args.budget)
        elif self.sampling_method == "adversary":
            self.sampler = sampler.AdversarySampler(self.args.budget)
        elif self.sampling_method == "uncertainty":
            self.sampler = sampler.UncertaintySampler(self.args.budget)
        elif self.sampling_method == "expected_error":
            self.sampler = sampler.EESampler(self.args.budget)
        elif self.sampling_method == "adversary_1c":
            self.sample = sampler.AdversarySamplerSingleClass(self.args.budget)


        else:
            raise Exception("No valid sampling method provideds")