-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support policy evaluation #137
Conversation
@@ -17,6 +17,7 @@ | |||
from omnisafe import algorithms | |||
from omnisafe.algorithms import ALGORITHMS | |||
from omnisafe.algorithms.algo_wrapper import AlgoWrapper as Agent | |||
from omnisafe.evaluator import Evaluator | |||
|
|||
# from omnisafe.algorithms.env_wrapper import EnvWrapper as Env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# from omnisafe.algorithms.env_wrapper import EnvWrapper as Env |
omnisafe/evaluator.py
Outdated
print(f'Episode cost: {ep_cost}') | ||
print(f'Episode length: {length}') | ||
|
||
print('#' * 50) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- self.xxx
done = False | ||
while not done and step <= 2000: # a big number to make sure the episode will end | ||
with torch.no_grad(): | ||
act = self._actor.predict(obs, deterministic=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why deterministic = False?
omnisafe/common/normalizer.py
Outdated
@@ -14,7 +14,7 @@ | |||
# ============================================================================== | |||
"""Implementation of Vector Buffer.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vector Buffer should not appear in this file.
self.__set_render_mode(play, save_replay) | ||
|
||
def __set_render_mode(self, play: bool = True, save_replay: bool = True): | ||
"""Set the render mode. | ||
|
||
Args: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the Args
in the comment do not match the real function arguments.
|
||
Args: | ||
env (gym.Env): The environment. | ||
actor (omnisafe.actor.Actor): The actor. | ||
save_dir (str): directory where the model is saved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same problems
omnisafe/evaluator.py
Outdated
|
||
Returns: | ||
episode_rewards (list): list of episode rewards. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to fix,
return ( episode_rewards, episode_costs, )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Co-authored-by: ruiyang sun <[email protected]>
Co-authored-by: ruiyang sun <[email protected]>
Co-authored-by: ruiyang sun <[email protected]>
Co-authored-by: ruiyang sun <[email protected]>
Co-authored-by: ruiyang sun <[email protected]>
Description
feat: support policy evaluation
Types of changes
What types of changes does your code introduce? Put an
x
in all the boxes that apply:Checklist
Go over all the following points, and put an
x
in all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!
make format
. (required)make lint
. (required)make test
pass. (required)