Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzhangliu committed Oct 20, 2023
1 parent 2484e83 commit 95f8b9c
Show file tree
Hide file tree
Showing 878 changed files with 2,907 additions and 5,112 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
logs/
dist/
.eggs/
xuanpolicy.egg-info/
xuance.egg-info/
models/
*.sh
.VSCodeCounter/
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MIT License
Copyright (c) 2018 XuanPolicy contributors
Copyright (c) 2018 XuanCe contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
Expand Down
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
![logo](./docs/source/figures/logo_1.png)

# XuanPolicy: A Comprehensive and Unified Deep Reinforcement Learning Library
# XuanCe: A Comprehensive and Unified Deep Reinforcement Learning Library

[![PyPI](https://img.shields.io/pypi/v/xuanpolicy)](https://pypi.org/project/xuanpolicy/)
[![Documentation Status](https://readthedocs.org/projects/xuanpolicy/badge/?version=latest)](https://xuanpolicy.readthedocs.io/en/latest/?badge=latest)
![GitHub](https://img.shields.io/github/license/agi-brain/xuanpolicy)
![GitHub Repo stars](https://img.shields.io/github/stars/agi-brain/xuanpolicy?style=social)
![GitHub forks](https://img.shields.io/github/forks/agi-brain/xuanpolicy?style=social)
![GitHub watchers](https://img.shields.io/github/watchers/agi-brain/xuanpolicy?style=social)
[![PyPI](https://img.shields.io/pypi/v/xuance)](https://pypi.org/project/xuance/)
[![Documentation Status](https://readthedocs.org/projects/xuance/badge/?version=latest)](https://xuance.readthedocs.io/en/latest/?badge=latest)
![GitHub](https://img.shields.io/github/license/agi-brain/xuance)
![GitHub Repo stars](https://img.shields.io/github/stars/agi-brain/xuance?style=social)
![GitHub forks](https://img.shields.io/github/forks/agi-brain/xuance?style=social)
![GitHub watchers](https://img.shields.io/github/watchers/agi-brain/xuance?style=social)

[![PyTorch](https://img.shields.io/badge/PyTorch-%3E%3D1.13.0-red)](https://pytorch.org/get-started/locally/)
[![TensorFlow](https://img.shields.io/badge/TensorFlow-%3E%3D2.6.0-orange)](https://www.tensorflow.org/install)
Expand All @@ -18,7 +18,7 @@
[![gymnasium](https://img.shields.io/badge/gymnasium-%3E%3D0.28.1-blue)](https://www.gymlibrary.dev/)
[![pettingzoo](https://img.shields.io/badge/PettingZoo-%3E%3D1.23.0-blue)](https://pettingzoo.farama.org/)

**XuanPolicy** is an open-source ensemble of Deep Reinforcement Learning (DRL) algorithm implementations.
**XuanCe** is an open-source ensemble of Deep Reinforcement Learning (DRL) algorithm implementations.

We call it as **Xuan-Ce (玄策)** in Chinese.
"**Xuan (玄)**" means incredible and magic box, "**Ce (策)**" means policy.
Expand All @@ -34,9 +34,9 @@ We expect it to be compatible with multiple deep learning toolboxes(
**[MindSpore](https://www.mindspore.cn/en)**),
and hope it can really become a zoo full of DRL algorithms.

| **[Full Documentation](https://xuanpolicy.readthedocs.io/en/latest)** |
**[中文文档](https://xuanpolicy.readthedocs.io/zh/latest/)** |
**[OpenI (启智社区)](https://openi.pcl.ac.cn/OpenRelearnware/XuanPolicy)** |
| **[Full Documentation](https://xuance.readthedocs.io/en/latest)** |
**[中文文档](https://xuance.readthedocs.io/zh/latest/)** |
**[OpenI (启智社区)](https://openi.pcl.ac.cn/OpenRelearnware/XuanCe)** |
**[XuanCe (Mini version)](https://github.com/wzcai99/xuance)** |

## Currently Included Algorithms
Expand Down Expand Up @@ -242,10 +242,10 @@ StarCraft Multi-Agentt Challenge.

The library can be run at Linux, Windows, MacOS, and EulerOS, etc.

Before installing **XuanPolicy**, you should install [Anaconda](https://www.anaconda.com/download) to prepare a python environment.
Before installing **XuanCe**, you should install [Anaconda](https://www.anaconda.com/download) to prepare a python environment.
(Note: select a proper version of Anaconda from [**here**](https://repo.anaconda.com/archive/).)

After that, open a terminal and install **XuanPolicy** by the following steps.
After that, open a terminal and install **XuanCe** by the following steps.

**Step 1**: Create a new conda environment (python>=3.7 is suggested):

Expand All @@ -262,14 +262,14 @@ conda activate xpolicy
**Step 3**: Install the library:

```commandline
pip install xuanpolicy
pip install xuance
```

This command does not include the dependencies of deep learning toolboxes. To install the **XuanPolicy** with
deep learning tools, you can type `pip install xuanpolicy[torch]` for [PyTorch](https://pytorch.org/get-started/locally/),
`pip install xuanpolicy[tensorflow]` for [TensorFlow2](https://www.tensorflow.org/install),
`pip install xuanpolicy[mindspore]` for [MindSpore](https://www.mindspore.cn/install/en),
and `pip install xuanpolicy[all]` for all dependencies.
This command does not include the dependencies of deep learning toolboxes. To install the **XuanCe** with
deep learning tools, you can type `pip install xuance[torch]` for [PyTorch](https://pytorch.org/get-started/locally/),
`pip install xuance[tensorflow]` for [TensorFlow2](https://www.tensorflow.org/install),
`pip install xuance[mindspore]` for [MindSpore](https://www.mindspore.cn/install/en),
and `pip install xuance[all]` for all dependencies.

Note: Some extra packages should be installed manually for further usage.

Expand All @@ -280,7 +280,7 @@ Note: Some extra packages should be installed manually for further usage.
#### Train a Model

```python
import xuanpolicy as xp
import xuance as xp

runner = xp.get_runner(method='dqn',
env='classic_control',
Expand All @@ -292,7 +292,7 @@ runner.run()
#### Test the Model

```python
import xuanpolicy as xp
import xuance as xp

runner_test = xp.get_runner(method='dqn',
env='classic_control',
Expand Down Expand Up @@ -485,8 +485,8 @@ $ tensorboard --logdir ./logs/dqn/torch/CartPole-v0
[//]: # (| micro_focus | | | | | | | | |)

```
@misc{XuanPolicy2023,
title={XuanPolicy: A Comprehensive and Unified Deep Reinforcement Learning Library},
@misc{XuanCe2023,
title={XuanCe: A Comprehensive and Unified Deep Reinforcement Learning Library},
author={Wenzhang Liu, Wenzhe Cai, Kun Jiang, Guangran Cheng, Yuanda Wang,
Jiawei Wang, Jingyu Cao, Lele Xu, Chaoxu Mu, Changyin Sun},
publisher = {GitHub},
Expand Down
2 changes: 1 addition & 1 deletion benchmark.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
from xuanpolicy import get_runner
from xuance import get_runner


def parse_args():
Expand Down
2 changes: 1 addition & 1 deletion benchmark_marl.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
from xuanpolicy import get_runner
from xuance import get_runner


def parse_args():
Expand Down
2 changes: 1 addition & 1 deletion demo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
from xuanpolicy import get_runner
from xuance import get_runner


def parse_args():
Expand Down
4 changes: 2 additions & 2 deletions demo_marl.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse

import xuanpolicy.torch.agents
from xuanpolicy import get_runner
import xuance.torch.agents
from xuance import get_runner


def parse_args():
Expand Down
12 changes: 6 additions & 6 deletions docs/build/html/_sources/documents/api/agents/drl/a2c.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ A2C_Agent
**PyTorch:**

.. py:class::
xuanpolicy.torch.agent.policy_gradient.a2c_agent.A2C_Agent(config, envs, policy, optimizer, scheduler, device)
xuance.torch.agent.policy_gradient.a2c_agent.A2C_Agent(config, envs, policy, optimizer, scheduler, device)

:param config: Provides hyper parameters.
:type config: Namespace
:param envs: The vectorized environments.
:type envs: xuanpolicy.environments.vector_envs.vector_env.VecEnv
:type envs: xuance.environments.vector_envs.vector_env.VecEnv
:param policy: The policy that provides actions and values.
:type policy: nn.Module
:param optimizer: The optimizer that updates the parameters.
Expand All @@ -24,7 +24,7 @@ A2C_Agent
:type device: str, int, torch.device

.. py:function::
xuanpolicy.torch.agent.policy_gradient.a2c_agent.A2C_Agent._action(obs)
xuance.torch.agent.policy_gradient.a2c_agent.A2C_Agent._action(obs)

Calculate actions according to the observations.

Expand All @@ -34,15 +34,15 @@ A2C_Agent
:rtype: np.ndarray, np.ndarray

.. py:function::
xuanpolicy.torch.agent.policy_gradient.a2c_agent.A2C_Agent.train(train_steps)
xuance.torch.agent.policy_gradient.a2c_agent.A2C_Agent.train(train_steps)

Train the A2C agent.

:param train_steps: The number of steps for training.
:type train_steps: int

.. py:function::
xuanpolicy.torch.agent.policy_gradient.a2c_agent.A2C_Agent.test(env_fn, test_episodes)
xuance.torch.agent.policy_gradient.a2c_agent.A2C_Agent.test(env_fn, test_episodes)

Test the trained model.

Expand Down Expand Up @@ -79,7 +79,7 @@ Source Code
import numpy as np
from xuanpolicy.torch.agents import *
from xuance.torch.agents import *
class A2C_Agent(Agent):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
Agent
=======================

To create a new Agent, you should build a class inherit from ``xuanpolicy.torch.agents.agent.Agent`` , ``xuanpolicy.tensorflow.agents.agent.Agent``, or ``xuanpolicy.mindspore.agents.agent.Agent``.
To create a new Agent, you should build a class inherit from ``xuance.torch.agents.agent.Agent`` , ``xuance.tensorflow.agents.agent.Agent``, or ``xuance.mindspore.agents.agent.Agent``.

**PyTorch:**

.. py:class::
xuanpolicy.torch.agents.agent.Agent(config, envs, policy, memory, learner, device, log_dir, model_dir)
xuance.torch.agents.agent.Agent(config, envs, policy, memory, learner, device, log_dir, model_dir)

:param config: Provides hyper parameters.
:type config: Namespace
:param envs: The vectorized environments.
:type envs: xuanpolicy.environments.vector_envs.vector_env.VecEnv
:type envs: xuance.environments.vector_envs.vector_env.VecEnv
:param policy: The policy that provides actions and values.
:type policy: nn.Module
:param memory: Experice replay buffer.
:type memory: xuanpolicy.common.memory_tools.Buffer
:type memory: xuance.common.memory_tools.Buffer
:param learner: The learner that updates parameters of policy.
:type learner: xuanpolicy.torch.learner.Learner
:type learner: xuance.torch.learner.Learner
:param device: Choose CPU or GPU to train the model.
:type device: str, int, torch.device
:param log_dir: The directory of log file, default is "./logs/".
:type log_dir: str
:param model_dir: The directory of model file, default is "./models/".
:type model_dir: str

.. py:function:: xuanpolicy.torch.agents.agent.Agent.save_model(model_name)
.. py:function:: xuance.torch.agents.agent.Agent.save_model(model_name)
Save the model.

:param model_name: The model's name to be saved.
:type model_name: str

.. py:function:: xuanpolicy.torch.agents.agent.Agent.load_model(path, seed)
.. py:function:: xuance.torch.agents.agent.Agent.load_model(path, seed)
Load a model by specifying the ``path`` and ``seed`` .

Expand All @@ -41,7 +41,7 @@ To create a new Agent, you should build a class inherit from ``xuanpolicy.torch.
:param seed: Select the seed that model was trained with if it exits.
:type seed: int

.. py:function:: xuanpolicy.torch.agents.agent.Agent.log_infos(info, x_index)
.. py:function:: xuance.torch.agents.agent.Agent.log_infos(info, x_index)
Visualize the training information via wandb or tensorboard.

Expand All @@ -50,7 +50,7 @@ To create a new Agent, you should build a class inherit from ``xuanpolicy.torch.
:param x_index: Current step.
:type x_index: int

.. py:function:: xuanpolicy.torch.agents.agent.Agent.log_videos(info, fps x_index)
.. py:function:: xuance.torch.agents.agent.Agent.log_videos(info, fps x_index)
Visualize the interaction between agent and environment by uploading the videos with wandb or tensorboard.

Expand All @@ -61,7 +61,7 @@ To create a new Agent, you should build a class inherit from ``xuanpolicy.torch.
:param x_index: Current step.
:type x_index: int

.. py:function:: xuanpolicy.torch.agents.agent.Agent._process_observation(observations)
.. py:function:: xuance.torch.agents.agent.Agent._process_observation(observations)
Normalize the original observations.

Expand All @@ -70,7 +70,7 @@ To create a new Agent, you should build a class inherit from ``xuanpolicy.torch.
:return: The normalized observations.
:rtype: numpy.ndarray

.. py:function:: xuanpolicy.torch.agents.agent.Agent._process_reward(rewards)
.. py:function:: xuance.torch.agents.agent.Agent._process_reward(rewards)
Normalize the original rewards.

Expand All @@ -79,29 +79,29 @@ To create a new Agent, you should build a class inherit from ``xuanpolicy.torch.
:return: The normalized observations rewards.
:rtype: numpy.ndarray

.. py:function:: xuanpolicy.torch.agents.agent.Agent._action(observations)
.. py:function:: xuance.torch.agents.agent.Agent._action(observations)
Get actions for executing according to the observations.

:param observations: The original observations of agent.
:type observations: numpy.ndarray

.. py:function:: xuanpolicy.torch.agents.agent.Agent.train(steps)
.. py:function:: xuance.torch.agents.agent.Agent.train(steps)
Train the agents with ``steps`` steps.

:param steps: The training steps.
:type steps: int

.. py:function:: xuanpolicy.torch.agents.agent.Agent.test(env_fn, steps)
.. py:function:: xuance.torch.agents.agent.Agent.test(env_fn, steps)
Test the agents.

:param env_fn: The function of making environments.
:param steps: The training steps.
:type steps: int

.. py:function:: xuanpolicy.torch.agents.agent.Agent.finish()
.. py:function:: xuance.torch.agents.agent.Agent.finish()
Finish the wandb or tensorboard.

Expand All @@ -113,18 +113,18 @@ To create a new Agent, you should build a class inherit from ``xuanpolicy.torch.
**TensorFlow:**

.. py:class::
xuanpolicy.tensorflowtensorflow.agent.agent.Agent(config, envs, policy, memory, learner, device, log_dir, model_dir)
xuance.tensorflowtensorflow.agent.agent.Agent(config, envs, policy, memory, learner, device, log_dir, model_dir)

:param config: Provides hyper parameters.
:type config: Namespace
:param envs: The vectorized environments.
:type envs: xuanpolicy.environments.vector_envs.vector_env.VecEnv
:type envs: xuance.environments.vector_envs.vector_env.VecEnv
:param policy: The policy that provides actions and values.
:type policy: nn.Module
:param memory: Experice replay buffer.
:type memory: xuanpolicy.common.memory_tools.Buffer
:type memory: xuance.common.memory_tools.Buffer
:param learner: The learner that updates parameters of policy.
:type learner: xuanpolicy.tensorflow.learner.Learner
:type learner: xuance.tensorflow.learner.Learner
:param device: Choose CPU or GPU to train the model.
:type device: str
:param log_dir: The directory of log file, default is "./logs/".
Expand All @@ -140,16 +140,16 @@ To create a new Agent, you should build a class inherit from ``xuanpolicy.torch.
**MindSpore:**

.. py:class::
xuanpolicy.mindsporetensorflow.agent.agent.Agent(envs, policy, memory, learner, device, log_dir, model_dir)
xuance.mindsporetensorflow.agent.agent.Agent(envs, policy, memory, learner, device, log_dir, model_dir)

:param envs: The vectorized environments.
:type envs: xuanpolicy.environments.vector_envs.vector_env.VecEnv
:type envs: xuance.environments.vector_envs.vector_env.VecEnv
:param policy: The policy that provides actions and values.
:type policy: nn.Module
:param memory: Experice replay buffer.
:type memory: xuanpolicy.common.memory_tools.Buffer
:type memory: xuance.common.memory_tools.Buffer
:param learner: The learner that updates parameters of policy.
:type learner: xuanpolicy.mindspore.learner.Learner
:type learner: xuance.mindspore.learner.Learner
:param device: Choose CPU or GPU to train the model.
:type device: str
:param log_dir: The directory of log file, default is "./logs/".
Expand Down
Loading

0 comments on commit 95f8b9c

Please sign in to comment.