Skip to content

Commit

Permalink
Fix typo in README and import error (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobHuangC authored Sep 23, 2023
1 parent 8502b7d commit 8151bd7
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ OSRL uses the `WandbLogger` in [FSRL](https://github.com/liuzuxin/FSRL) and [Pyr
For example, to train the `bcql` method, simply run by overriding the default parameters:

```shell
python examples/train/train_bcql.py --task OfflineCarCirvle-v0 --param1 args1 ...
python examples/train/train_bcql.py --task OfflineCarCircle-v0 --param1 args1 ...
```
By default, the config file and the logs during training will be written to `logs\` folder and the training plots can be viewed online using Wandb.

You can also launch a sequence of experiments or in parallel via the [EasyRunner](https://github.com/liuzuxin/easy-runner) package, see `examples/train_all_tasks.py` for details.

### Evaluation
To evaluate a trained agent, for example, a BCQ agent, simply run
```
python example/eval/eval_bcql.py --path path_to_model --eval_episodes 20
```shell
python examples/eval/eval_bcql.py --path path_to_model --eval_episodes 20
```
It will load config file from `path_to_model/config.yaml` and model file from `path_to_model/checkpoints/model.pt`, run 20 episodes, and print the average normalized reward and cost. The pretrained checkpoints for all datasets are available [here](https://drive.google.com/drive/folders/1lZmw2NVNR4YGUdrkih9o3rTMDrWCI_jw?usp=sharing) for reference.

Expand Down
4 changes: 3 additions & 1 deletion examples/eval/eval_bc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import Any, DefaultDict, Dict, List, Optional, Tuple

import dsrl
import gymnasium as gym # noqa
import numpy as np
import pyrallis
import torch
Expand Down Expand Up @@ -33,6 +32,9 @@ def eval(args: EvalConfig):

if "Metadrive" in cfg["task"]:
import gym
else:
import gymnasium as gym # noqa

env = gym.make(cfg["task"])
env.set_target_cost(cfg["cost_limit"])

Expand Down
4 changes: 3 additions & 1 deletion examples/eval/eval_bcql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import Any, DefaultDict, Dict, List, Optional, Tuple

import dsrl
import gymnasium as gym # noqa
import numpy as np
import pyrallis
import torch
Expand Down Expand Up @@ -33,6 +32,9 @@ def eval(args: EvalConfig):

if "Metadrive" in cfg["task"]:
import gym
else:
import gymnasium as gym # noqa

env = wrap_env(
env=gym.make(cfg["task"]),
reward_scale=cfg["reward_scale"],
Expand Down
4 changes: 3 additions & 1 deletion examples/eval/eval_bearl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import Any, DefaultDict, Dict, List, Optional, Tuple

import dsrl
import gymnasium as gym # noqa
import numpy as np
import pyrallis
import torch
Expand Down Expand Up @@ -33,6 +32,9 @@ def eval(args: EvalConfig):

if "Metadrive" in cfg["task"]:
import gym
else:
import gymnasium as gym # noqa

env = wrap_env(
env=gym.make(cfg["task"]),
reward_scale=cfg["reward_scale"],
Expand Down
4 changes: 3 additions & 1 deletion examples/eval/eval_cdt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import Any, DefaultDict, Dict, List, Optional, Tuple

import dsrl
import gymnasium as gym # noqa
import numpy as np
import pyrallis
import torch
Expand Down Expand Up @@ -35,6 +34,9 @@ def eval(args: EvalConfig):

if "Metadrive" in cfg["task"]:
import gym
else:
import gymnasium as gym # noqa

env = wrap_env(
env=gym.make(cfg["task"]),
reward_scale=cfg["reward_scale"],
Expand Down
4 changes: 3 additions & 1 deletion examples/eval/eval_coptidice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import Any, DefaultDict, Dict, List, Optional, Tuple

import dsrl
import gymnasium as gym # noqa
import numpy as np
import pyrallis
import torch
Expand Down Expand Up @@ -33,6 +32,9 @@ def eval(args: EvalConfig):

if "Metadrive" in cfg["task"]:
import gym
else:
import gymnasium as gym # noqa

env = wrap_env(
env=gym.make(cfg["task"]),
reward_scale=cfg["reward_scale"],
Expand Down
4 changes: 3 additions & 1 deletion examples/eval/eval_cpq.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import Any, DefaultDict, Dict, List, Optional, Tuple

import dsrl
import gymnasium as gym # noqa
import numpy as np
import pyrallis
import torch
Expand Down Expand Up @@ -33,6 +32,9 @@ def eval(args: EvalConfig):

if "Metadrive" in cfg["task"]:
import gym
else:
import gymnasium as gym # noqa

env = wrap_env(
env=gym.make(cfg["task"]),
reward_scale=cfg["reward_scale"],
Expand Down

0 comments on commit 8151bd7

Please sign in to comment.