-
Notifications
You must be signed in to change notification settings - Fork 126
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
[Question] Customizing my algorithem #278
Comments
Thank you very much for your recognition. OmniSafe provides support for flexible algorithm customization. You can achieve algorithm customization by simple inheritance and overriding. Suppose you need to implement a
# Copyright 2023 OmniSafe Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Implementation of the customization of the TRPO algorithm."""
from omnisafe.algorithms import registry
from omnisafe.algorithms.on_policy.base.trpo import TRPO
@registry.register
class CustomTRPO(TRPO):
"""The customization of the TRPO algorithm."""
# You can customize the algorithm by overriding the methods in TRPO
# or adding new methods.
# Copyright 2023 OmniSafe Team. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Basic Reinforcement Learning algorithms."""
from omnisafe.algorithms.on_policy.base.natural_pg import NaturalPG
from omnisafe.algorithms.on_policy.base.policy_gradient import PolicyGradient
from omnisafe.algorithms.on_policy.base.ppo import PPO
from omnisafe.algorithms.on_policy.base.trpo import TRPO
from omnisafe.algorithms.on_policy.base.custom_trpo import CustomTRPO
__all__ = [
'NaturalPG',
'PolicyGradient',
'PPO',
'TRPO',
'CustomTRPO'
]
cd examples
python train_policy.py --algo CustomTRPO. By following these steps, you will be able to customize |
Thank you for your reply, it really solve my question. |
Feel free to open an issue whenever you encounter problem. |
Required prerequisites
Questions
As a beginner in safety RL, I'm very grateful to omnisafe'help for me.
I would like to implement customised algorithm based on algorithms in omnisafe. For example:
`
from omnisafe.algorithms.on_policy.base.trpo import TRPO
class Cust_algo(TRPO):
......
env_id = 'SafetyPointGoal0-v0'
agent = omnisafe.Agent('Cust_algo', env_id)
agent.learn()
`
What should I do to make it works? Or is there any other method making the same target achieved?
Once again, thank you for your efforts, and I look forward to your response. Thank you!
The text was updated successfully, but these errors were encountered: