Skip to content
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

Merged
merged 8 commits into from
Mar 10, 2023
Merged

feat: support policy evaluation #137

merged 8 commits into from
Mar 10, 2023

Conversation

Gaiejj
Copy link
Member

@Gaiejj Gaiejj commented Mar 7, 2023

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:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)

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!

  • I have read the CONTRIBUTION guide. (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly. (required for a bug fix or a new feature)
  • I have updated the documentation accordingly.
  • I have reformatted the code using make format. (required)
  • I have checked the code using make lint. (required)
  • I have ensured make test pass. (required)

@Gaiejj Gaiejj requested review from rockmagma02 and zmsn-2077 and removed request for rockmagma02 March 8, 2023 02:21
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# from omnisafe.algorithms.env_wrapper import EnvWrapper as Env

print(f'Episode cost: {ep_cost}')
print(f'Episode length: {length}')

print('#' * 50)
Copy link
Collaborator

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why deterministic = False?

@@ -14,7 +14,7 @@
# ==============================================================================
"""Implementation of Vector Buffer."""
Copy link
Member

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:
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same problems


Returns:
episode_rewards (list): list of episode rewards.
Copy link
Member

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, )

Copy link
Member

@zmsn-2077 zmsn-2077 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@Gaiejj Gaiejj requested a review from zmsn-2077 March 10, 2023 01:48
Copy link
Member

@zmsn-2077 zmsn-2077 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@Gaiejj Gaiejj merged commit 5f37e02 into PKU-Alignment:dev Mar 10, 2023
@Gaiejj Gaiejj deleted the dev-eval branch March 14, 2023 02:43
zmsn-2077 pushed a commit to zmsn-2077/omnisafe_zmsn that referenced this pull request Mar 14, 2023
Co-authored-by: ruiyang sun <rockmagma02@gmail.com>
zmsn-2077 pushed a commit to zmsn-2077/omnisafe_zmsn that referenced this pull request Mar 14, 2023
Co-authored-by: ruiyang sun <rockmagma02@gmail.com>
zmsn-2077 pushed a commit to zmsn-2077/omnisafe_zmsn that referenced this pull request Mar 14, 2023
Co-authored-by: ruiyang sun <rockmagma02@gmail.com>
zmsn-2077 pushed a commit that referenced this pull request Mar 14, 2023
Co-authored-by: ruiyang sun <rockmagma02@gmail.com>
zmsn-2077 pushed a commit that referenced this pull request Mar 15, 2023
Co-authored-by: ruiyang sun <rockmagma02@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants