Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
muchvo committed Apr 23, 2024
1 parent c1f7620 commit 50afc8d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions omnisafe/adapter/crabs_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ def eval_policy( # pylint: disable=too-many-locals

logger.store(
{
'Metrics/TestEpRet': ep_ret,
'Metrics/TestEpCost': ep_cost,
'Metrics/TestEpLen': ep_len,
'Metrics/RawPolicyEpRet': ep_ret,
'Metrics/RawPolicyEpCost': ep_cost,
'Metrics/RawPolicyEpLen': ep_len,
},
)

Expand Down
7 changes: 5 additions & 2 deletions omnisafe/algorithms/off_policy/crabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ def _init_log(self) -> None:
what_to_save['obs_normalizer'] = self.normalizer
self._logger.setup_torch_saver(what_to_save)
self._logger.torch_save()
self._logger.register_key('Metrics/RawPolicyEpRet', window_length=50)
self._logger.register_key('Metrics/RawPolicyEpCost', window_length=50)
self._logger.register_key('Metrics/RawPolicyEpLen', window_length=50)

def _init(self) -> None:
"""The initialization of the algorithm.
Expand Down Expand Up @@ -278,7 +281,7 @@ def learn(self):

eval_start = time.time()
self._env.eval_policy(
episode=self._cfgs.train_cfgs.eval_episodes,
episode=self._cfgs.train_cfgs.raw_policy_episodes,
agent=self._actor_critic,
logger=self._logger,
)
Expand Down Expand Up @@ -326,7 +329,7 @@ def learn(self):
if t % 1000 == 0:
eval_start = time.time()
self._env.eval_policy(
episode=self._cfgs.train_cfgs.eval_episodes,
episode=self._cfgs.train_cfgs.raw_policy_episodes,
agent=self.mean_policy, # type: ignore
logger=self._logger,
)
Expand Down
3 changes: 2 additions & 1 deletion omnisafe/configs/off-policy/CRABS.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ defaults:
# number of training epochs
num_epochs: 101
# number of evaluate episodes
eval_episodes: 10
eval_episodes: 0
raw_policy_episodes: 10
# algorithm configurations
algo_cfgs:
# number of steps to update the policy
Expand Down
8 changes: 5 additions & 3 deletions tests/.coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ omit =
../docs/*
../examples/*
../tutorials/*
../common/control_barrier_function/crabs/*
../envs/classic_control/*
../algorithms/off_policy/crabs.py
../omnisafe/common/control_barrier_function/crabs/*
../omnisafe/envs/classic_control/*
../omnisafe/algorithms/off_policy/crabs.py
../omnisafe/adapter/crabs_adapter.py
../omnisafe/envs/crabs_env.py

[report]
exclude_lines =
Expand Down

0 comments on commit 50afc8d

Please sign in to comment.