(self)
run
run
run
def run(self):
        """
            run
        """
        rewards = []
        mid = 0
        while mid <= self.num_models:
            actions_to, actions_ad = self.autodl_agent.sample()

            for action in zip(actions_to, actions_ad):
                utils.dump_action(mid, action, self.log_dir)
                self.supervisor(mid)
                current_reward = utils.load_reward(mid, self.log_dir)
                if not np.isnan(current_reward):
                    rewards.append(current_reward.item())
                mid += 1

            if len(rewards) % self.batch_size == 0:
                print("[%s] step = %d, average accuracy = %.3f" %
                      (utils.stime(), self.autodl_agent.global_step,
                       np.mean(rewards)))
                rewards_array = np.array(rewards).astype("float32")
                if self.total_reward == 0:
                    self.total_reward = rewards_array.mean()
                else:
                    self.total_reward = self.total_reward * self.bl_decay \
                            + (1 - self.bl_decay) * rewards_array.mean()
                rewards_array = rewards_array - self.total_reward
                self.autodl_agent.learn([actions_to.astype("int32"),
                                         actions_ad.astype("int32")],
                                        rewards_array ** 3)
                rewards = []
def run ( self ) : rewards = [ ] mid = 0 while mid <= self . num_models : actions_to , actions_ad = self . autodl_agent . sample ( ) for action in zip ( actions_to , actions_ad ) : utils . dump_action ( mid , action , self . log_dir ) self . supervisor ( mid ) current_reward = utils . load_reward ( mid , self . log_dir ) if not np . isnan ( current_reward ) : rewards . append ( current_reward . item ( ) ) mid += 1 if len ( rewards ) % self . batch_size == 0 : print ( "[%s] step = %d, average accuracy = %.3f" % ( utils . stime ( ) , self . autodl_agent . global_step , np . mean ( rewards ) ) ) rewards_array = np . array ( rewards ) . astype ( "float32" ) if self . total_reward == 0 : self . total_reward = rewards_array . mean ( ) else : self . total_reward = self . total_reward * self . bl_decay + ( 1 - self . bl_decay ) * rewards_array . mean ( ) rewards_array = rewards_array - self . total_reward self . autodl_agent . learn ( [ actions_to . astype ( "int32" ) , actions_ad . astype ( "int32" ) ] , rewards_array ** 3 ) rewards = [ ]