예제 #1
0
    def get_evo_temp(cur_step):
        """randomly get different temperature according to current adversarial step"""
        mu_temp_type = cfg.mu_temp.split()
        all_temp = list()

        # all_temp.append(get_fixed_temperature(1.0, 0, 0, 'no'))  # temp=1.0
        all_temp.append(
            get_fixed_temperature(cfg.temperature, cur_step,
                                  cfg.ADV_train_epoch,
                                  random.choice(mu_temp_type)))  # current step
        all_temp.append(
            get_fixed_temperature(cfg.temperature,
                                  cur_step + cfg.evo_temp_step,
                                  cfg.ADV_train_epoch,
                                  random.choice(mu_temp_type)))
        if cur_step > cfg.evo_temp_step:
            all_temp.append(
                get_fixed_temperature(cfg.temperature,
                                      cur_step - cfg.evo_temp_step,
                                      cfg.ADV_train_epoch,
                                      random.choice(mu_temp_type)))

        return torch.Tensor(all_temp)  # three temp
예제 #2
0
 def update_temperature(self, i, N):
     self.gen.temperature = get_fixed_temperature(cfg.temperature, i, N, cfg.temp_adpt)
예제 #3
0
 def update_temperature(self, i, N):
     self.gen.temperature.data = torch.Tensor([get_fixed_temperature(cfg.temperature, i, N, cfg.temp_adpt)])
     if cfg.CUDA:
         self.gen.temperature.data = self.gen.temperature.data.cuda()