Skip to content

Instantly share code, notes, and snippets.

@MCarlomagno
Last active January 20, 2022 18:42
Show Gist options
  • Save MCarlomagno/3caf4653ca092cbcf2c90bf8cfa7a7f3 to your computer and use it in GitHub Desktop.
Save MCarlomagno/3caf4653ca092cbcf2c90bf8cfa7a7f3 to your computer and use it in GitHub Desktop.
class GymTask(Task):
# ...
def execute(self, *args: Any, **kwargs: Any) -> None:
if not self._proxy_env.is_rl_agent_trained and not self.is_rl_agent_training:
self._start_training()
if self._proxy_env.is_rl_agent_trained and self.is_rl_agent_training:
self._stop_training()
# ...
def _start_training(self) -> None:
self.is_rl_agent_training = True
self._fit(self._proxy_env, self.nb_steps)
def _stop_training(self) -> None:
if self.is_rl_agent_training:
self.is_rl_agent_training = False
self._proxy_env.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment