
文檔|實現的算法|安裝|入門|執照
Omnisafe是一種基礎設施框架,旨在加速安全的增強學習(RL)研究。它為安全的RL算法提供了全面可靠的基準,也為研究人員提供了一個箱外的模塊化工具包。 SAFERL打算開發算法,以最大程度地減少意外傷害或不安全行為的風險。
Omnisafe是安全強化學習領域的首個統一學習框架,旨在促進Saferl學習社區的發展。 Omnisafe的主要特徵:
高度模塊化的框架。 Omnisafe提出了一個高度模塊化的框架,其中包含了針對跨不同領域的安全加固學習量身定制的數十種算法。該框架通過使用適配器和包裝器設計組件的各種算法類型和精心設計的API進行抽象,因此該框架具有多功能性,並且可以在不同組件之間彌合間隙並實現無縫的相互作用。該設計可輕鬆擴展和自定義,使其成為使用不同類型算法的開發人員的強大工具。
高性能並行計算加速度。通過利用torch.distributed的功能。分配後,Omnisafe通過過程並行性加速了算法的學習過程。這使Omnisafe不僅可以支持環境級別的異步並行性,而且還融合了劑異步學習。這種方法可以增強訓練穩定性,並通過部署平行勘探機制來加快訓練過程。代理在Omnisafe中的代理學習的整合強調了其為提供一個多功能且強大的平台來推進SAFERL研究的承諾。
開箱即用的工具包。 Omnisafe提供可自定義的工具包,用於培訓,基準測試,分析和渲染等任務。教程和用戶友好的API使初學者和普通用戶可以輕鬆,而高級研究人員可以在沒有復雜代碼的情況下提高其效率。
如果您發現Omnisafe有用或在研究中使用Omnisafe,請在您的出版物中引用它。
@article { JMLR:v25:23-0681 ,
author = { Jiaming Ji and Jiayi Zhou and Borong Zhang and Juntao Dai and Xuehai Pan and Ruiyang Sun and Weidong Huang and Yiran Geng and Mickel Liu and Yaodong Yang } ,
title = { OmniSafe: An Infrastructure for Accelerating Safe Reinforcement Learning Research } ,
journal = { Journal of Machine Learning Research } ,
year = { 2024 } ,
volume = { 25 } ,
number = { 285 } ,
pages = { 1--6 } ,
url = { http://jmlr.org/papers/v25/23-0681.html }
}Omnisafe需要Python 3.8+和Pytorch 1.10+。
我們在Linux上支持和測試Python 3.8、3.9、3.10。同時,我們還支持MACOS的M1和M2版本。我們將接受與Windows相關的PR,但不正式支持它。
# Clone the repo
git clone https://github.com/PKU-Alignment/omnisafe.git
cd omnisafe
# Create a conda environment
conda env create --file conda-recipe.yaml
conda activate omnisafe
# Install omnisafe
pip install -e . Omnisafe託管在 /。
pip install omnisafe cd examples
python train_policy.py --algo PPOLag --env-id SafetyPointGoal1-v0 --parallel 1 --total-steps 10000000 --device cpu --vector-env-nums 1 --torch-threads 1| 域 | 類型 | 算法註冊表 |
|---|---|---|
| 關於政策 | 原始雙重 | trpolag; ppolag; PDO; RCPO |
| trpopid; cppopid | ||
| 凸優化 | CPO; pcpo;焦點;杯子 | |
| 懲罰功能 | IPO; P3O | |
| 原始 | oncrpo | |
| 政策 | 原始偶 | ddpglag; TD3LAG;薩克拉格 |
| DDPGPID; TD3PID;糖 | ||
| 基於模型 | 在線計劃 | Safeloop; ccepets; rcepets |
| 悲觀的估計 | 簽名 | |
| 離線 | 基於q學習 | bcqlag; C-Crr |
| 基於骰子 | coptdice | |
| 其他配方MDP | ET-MDP | PPO早產; trpoEarlyperminited |
| 索特爾 | pposaute; trposaute | |
| simmerrl | pposimmerpid; trposimmerpid |
這是安全gymnasium支持的環境列表:
| 類別 | 任務 | 代理人 | 例子 |
|---|---|---|---|
| 安全導航 | 目標[012] | 點,汽車,賽車,螞蟻 | safetypointgoal1-v0 |
| 按鈕[012] | |||
| 推[012] | |||
| 圓[012] | |||
| 安全速度 | 速度 | Halfcheetah,料斗,游泳者,沃克2D,螞蟻,人形生物 | 安全類固定級V1 |
| 安全的艾薩克體育館 | Appassafefinger | Shadowhand | Shadowhandoversafefinger |
| 超級安排 | |||
| catchover2underarmsafefinger | |||
| catchover2underarmsafeext |
有關環境的更多信息,請參閱安全gymnasium。
我們提供一個靈活的自定義環境界面,該界面允許用戶在不修改Omnisafe源代碼的情況下實現以下內容:
我們提供有關環境自定義和社區環境定制環境定制的分步教程,以詳細介紹如何使用Omnisafe的這種非凡功能。
注意:如果您發現自定義環境的麻煩,請隨時開放問題或討論。如果您願意貢獻環境接口的實現,也歡迎拉動請求。
pip install omnisafe
omnisafe --help # Ask for help
omnisafe benchmark --help # The benchmark also can be replaced with 'eval', 'train', 'train-config'
# Quick benchmarking for your research, just specify:
# 1. exp_name
# 2. num_pool(how much processes are concurrent)
# 3. path of the config file (refer to omnisafe/examples/benchmarks for format)
# Here we provide an exampe in ./tests/saved_source.
# And you can set your benchmark_config.yaml by following it
omnisafe benchmark test_benchmark 2 ./tests/saved_source/benchmark_config.yaml
# Quick evaluating and rendering your trained policy, just specify:
# 1. path of algorithm which you trained
omnisafe eval ./tests/saved_source/PPO-{SafetyPointGoal1-v0} --num-episode 1
# Quick training some algorithms to validate your thoughts
# Note: use `key1:key2`, your can select key of hyperparameters which are recursively contained, and use `--custom-cfgs`, you can add custom cfgs via CLI
omnisafe train --algo PPO --total-steps 2048 --vector-env-nums 1 --custom-cfgs algo_cfgs:steps_per_epoch --custom-cfgs 1024
# Quick training some algorithms via a saved config file, the format is as same as default format
omnisafe train-config ./tests/saved_source/train_config.yaml我們已經為各種算法提供了基準結果,包括上政策,基於模型,基於模型和離線方法以及參數調整分析。請參考以下內容:
通過一系列Google Colab筆記本輕鬆快速地探索omnisafe:
我們非常高興與用戶合作創建各種語言的教程。請參閱我們當前支持的語言列表。如果您有興趣將本教程轉換為新語言或改進現有版本,請向我們提交PR。
請參閱ChangElog.md。
我們已經編制了一份使用Omnisafe進行算法實施或實驗的論文列表。如果您願意將您的工作包括在此列表中,或者希望將實施正式集成到Omnisafe中,請隨時與我們聯繫。
| 文件 | 出版商 |
|---|---|
| 非政策原始雙重安全增強學習 | ICLR 2024 |
| 通過可行性引導的擴散模型安全離線增強學習 | ICLR 2024 |
| 安全加強學習的迭代可及性估算 | 神經2023 |
| 用於安全加強學習的平衡獎勵和安全優化:梯度操縱的視角 | AAAI 2024 |
| 使用一級決策樹從演示中學習安全限制 | AAAI 2024研討會 |
Omnisafe主要由Yaodong Yang教授執導的Saferl研究團隊開發。我們的Saferl研究團隊成員包括Borong Zhang,Jiayi Zhou,Jtao Dai,Weidong Huang,Ruiyang Sun,Xuehai Pan和Jiaming Ji。如果您在使用Omnisafe的過程中有任何疑問,請隨時在GitHub問題頁面上詢問您的問題,我們將在2-3個工作日內回复您。
Omnisafe以Apache許可證2.0發布。