def update_nets(self): if util.frame_mod(self.body.env.clock.frame, self.net.update_frequency, self.body.env.num_envs): if self.net.update_type == 'replace': net_util.copy(self.net, self.target_net) elif self.net.update_type == 'polyak': net_util.polyak_update(self.net, self.target_net, self.net.polyak_coef) else: raise ValueError('Unknown net.update_type. Should be "replace" or "polyak". Exiting.')
def to_ckpt(self, env, mode='eval'): '''Check with clock whether to run log/eval ckpt: at the start, save_freq, and the end''' if mode == 'eval' and util.in_eval_lab_modes(): # avoid double-eval: eval-ckpt in eval mode return False clock = env.clock frame = clock.get() frequency = env.eval_frequency if mode == 'eval' else env.log_frequency if frame == 0 or clock.get('opt_step') == 0: # avoid ckpt at init to_ckpt = False elif frequency is None: # default episodic to_ckpt = env.done else: # normal ckpt condition by mod remainder (general for venv) to_ckpt = util.frame_mod(frame, frequency, env.num_envs) or frame == clock.max_frame return to_ckpt