Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- .venv/lib/python3.11/site-packages/ray/rllib/algorithms/__pycache__/algorithm.cpython-311.pyc +3 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/curriculum/__init__.py +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/curriculum/__pycache__/__init__.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/curriculum/__pycache__/curriculum_learning.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/curriculum/curriculum_learning.py +241 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/__init__.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/agents_act_in_sequence.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/agents_act_simultaneously.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/async_gym_env_vectorization.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/custom_env_render_method.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/custom_gym_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/env_connecting_to_rllib_w_tcp_client.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/env_rendering_and_recording.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/env_w_protobuf_observations.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/greyscale_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/unity3d_env_local.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/__init__.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/action_mask_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/cartpole_crashing.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/cartpole_sparse_rewards.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/cartpole_with_dict_observation_space.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/cartpole_with_large_observation_space.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/cartpole_with_protobuf_observation_space.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/cliff_walking_wall_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/correlated_actions_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/d4rl_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/debug_counter_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/deterministic_envs.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/dm_control_suite.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/env_using_remote_actor.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/env_with_subprocess.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/fast_image_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/gpu_requiring_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/look_and_push.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/memory_leaking_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/mock_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/nested_space_repeat_after_me_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/parametric_actions_cartpole.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/random_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/recommender_system_envs_with_recsim.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/repeat_after_me_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/repeat_initial_obs_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/simple_corridor.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/simple_rpg.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/six_room_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/stateless_cartpole.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/stateless_pendulum.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/transformed_action_space_env.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/windy_maze_env.cpython-311.pyc +0 -0
.gitattributes
CHANGED
|
@@ -176,3 +176,4 @@ tuning-competition-baseline/.venv/lib/python3.11/site-packages/torch/_inductor/_
|
|
| 176 |
.venv/lib/python3.11/site-packages/ray/_private/__pycache__/worker.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 177 |
.venv/lib/python3.11/site-packages/ray/_private/__pycache__/test_utils.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 178 |
.venv/lib/python3.11/site-packages/ray/_private/thirdparty/pynvml/__pycache__/pynvml.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 176 |
.venv/lib/python3.11/site-packages/ray/_private/__pycache__/worker.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 177 |
.venv/lib/python3.11/site-packages/ray/_private/__pycache__/test_utils.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 178 |
.venv/lib/python3.11/site-packages/ray/_private/thirdparty/pynvml/__pycache__/pynvml.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 179 |
+
.venv/lib/python3.11/site-packages/ray/rllib/algorithms/__pycache__/algorithm.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
.venv/lib/python3.11/site-packages/ray/rllib/algorithms/__pycache__/algorithm.cpython-311.pyc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:95af77c4d005c6313bfda251ea72e8f78077efdc496424adc38b2ccc523d6af7
|
| 3 |
+
size 171335
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/curriculum/__init__.py
ADDED
|
File without changes
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/curriculum/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (202 Bytes). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/curriculum/__pycache__/curriculum_learning.cpython-311.pyc
ADDED
|
Binary file (8.52 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/curriculum/curriculum_learning.py
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Example of using an env-task curriculum by implementing a custom callback.
|
| 2 |
+
|
| 3 |
+
This example:
|
| 4 |
+
- demonstrates how to define your own curriculum-capable environments using
|
| 5 |
+
gymnasium's FrozenLake env.
|
| 6 |
+
- defines a custom callback that gets called once per iteration and - if necessary -
|
| 7 |
+
changes the maps used by FrozenLake on all EnvRunners to a new task (by moving the
|
| 8 |
+
goal position further and further away from the starting position).
|
| 9 |
+
- also demonstrates an alternative approach via reloading/recreating an entirely new
|
| 10 |
+
env inside all EnvRunners.
|
| 11 |
+
- uses Tune and RLlib to curriculum-learn the env described above and compares 2
|
| 12 |
+
algorithms, one that does use curriculum learning vs one that does not.
|
| 13 |
+
|
| 14 |
+
We use a FrozenLake (sparse reward) environment with a map size of 8x8 and a time step
|
| 15 |
+
limit of 16 to make it almost impossible for a non-curriculum policy to learn.
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
How to run this script
|
| 19 |
+
----------------------
|
| 20 |
+
`python [script file name].py --enable-new-api-stack`
|
| 21 |
+
|
| 22 |
+
Use the `--no-curriculum` flag to disable curriculum learning and force your policy
|
| 23 |
+
to be trained on the hardest task right away. With this option, the algorithm should NOT
|
| 24 |
+
succeed.
|
| 25 |
+
|
| 26 |
+
For debugging, use the following additional command line options
|
| 27 |
+
`--no-tune --num-env-runners=0`
|
| 28 |
+
which should allow you to set breakpoints anywhere in the RLlib code and
|
| 29 |
+
have the execution stop there for inspection and debugging.
|
| 30 |
+
|
| 31 |
+
For logging to your WandB account, use:
|
| 32 |
+
`--wandb-key=[your WandB API key] --wandb-project=[some project name]
|
| 33 |
+
--wandb-run-name=[optional: WandB run name (within the defined project)]`
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
Results to expect
|
| 37 |
+
-----------------
|
| 38 |
+
In the console output, you can see that only PPO policy that uses a curriculum can
|
| 39 |
+
actually learn, whereas the one that is thrown into the toughest task right from the
|
| 40 |
+
start never learns anything.
|
| 41 |
+
|
| 42 |
+
Policy using the curriculum:
|
| 43 |
+
+-------------------------------+------------+-----------------+--------+
|
| 44 |
+
| Trial name | status | loc | iter |
|
| 45 |
+
|-------------------------------+------------+-----------------+--------+
|
| 46 |
+
| PPO_FrozenLake-v1_93ca4_00000 | TERMINATED | 127.0.0.1:73318 | 41 |
|
| 47 |
+
+-------------------------------+------------+-----------------+--------+
|
| 48 |
+
+------------------+--------+----------+--------------------+
|
| 49 |
+
| total time (s) | ts | reward | episode_len_mean |
|
| 50 |
+
|------------------+--------+----------+--------------------|
|
| 51 |
+
| 97.652 | 164000 | 1 | 14.0348 |
|
| 52 |
+
+------------------+--------+----------+--------------------+
|
| 53 |
+
|
| 54 |
+
Policy NOT using the curriculum (trying to solve the hardest task right away):
|
| 55 |
+
[DOES NOT LEARN AT ALL]
|
| 56 |
+
"""
|
| 57 |
+
from functools import partial
|
| 58 |
+
|
| 59 |
+
from ray.air.constants import TRAINING_ITERATION
|
| 60 |
+
from ray.rllib.algorithms.algorithm import Algorithm
|
| 61 |
+
from ray.rllib.callbacks.callbacks import RLlibCallback
|
| 62 |
+
from ray.rllib.connectors.env_to_module import FlattenObservations
|
| 63 |
+
from ray.rllib.core.rl_module.default_model_config import DefaultModelConfig
|
| 64 |
+
from ray.rllib.utils.metrics import (
|
| 65 |
+
ENV_RUNNER_RESULTS,
|
| 66 |
+
EPISODE_RETURN_MEAN,
|
| 67 |
+
NUM_ENV_STEPS_SAMPLED_LIFETIME,
|
| 68 |
+
)
|
| 69 |
+
from ray.rllib.utils.test_utils import (
|
| 70 |
+
add_rllib_example_script_args,
|
| 71 |
+
run_rllib_example_script_experiment,
|
| 72 |
+
)
|
| 73 |
+
from ray.tune.registry import get_trainable_cls
|
| 74 |
+
|
| 75 |
+
parser = add_rllib_example_script_args(default_iters=100, default_timesteps=600000)
|
| 76 |
+
parser.set_defaults(enable_new_api_stack=True)
|
| 77 |
+
parser.add_argument(
|
| 78 |
+
"--upgrade-task-threshold",
|
| 79 |
+
type=float,
|
| 80 |
+
default=0.99,
|
| 81 |
+
help="The mean episode return, upon reaching of which we increase the task by one.",
|
| 82 |
+
)
|
| 83 |
+
parser.add_argument(
|
| 84 |
+
"--no-curriculum",
|
| 85 |
+
action="store_true",
|
| 86 |
+
help="Whether to NOT use curriculum learning (and instead trying to solve the "
|
| 87 |
+
"hardest task right away).",
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
# __curriculum_learning_example_env_options__
|
| 91 |
+
ENV_OPTIONS = {
|
| 92 |
+
"is_slippery": False,
|
| 93 |
+
# Limit the number of steps the agent is allowed to make in the env to
|
| 94 |
+
# make it almost impossible to learn without the curriculum.
|
| 95 |
+
"max_episode_steps": 16,
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
# Our 3 tasks: 0=easiest, 1=medium, 2=hard
|
| 99 |
+
ENV_MAPS = [
|
| 100 |
+
# 0
|
| 101 |
+
[
|
| 102 |
+
"SFFHFFFH",
|
| 103 |
+
"FFFHFFFF",
|
| 104 |
+
"FFGFFFFF",
|
| 105 |
+
"FFFFFFFF",
|
| 106 |
+
"HFFFFFFF",
|
| 107 |
+
"HHFFFFHF",
|
| 108 |
+
"FFFFFHHF",
|
| 109 |
+
"FHFFFFFF",
|
| 110 |
+
],
|
| 111 |
+
# 1
|
| 112 |
+
[
|
| 113 |
+
"SFFHFFFH",
|
| 114 |
+
"FFFHFFFF",
|
| 115 |
+
"FFFFFFFF",
|
| 116 |
+
"FFFFFFFF",
|
| 117 |
+
"HFFFFFFF",
|
| 118 |
+
"HHFFGFHF",
|
| 119 |
+
"FFFFFHHF",
|
| 120 |
+
"FHFFFFFF",
|
| 121 |
+
],
|
| 122 |
+
# 2
|
| 123 |
+
[
|
| 124 |
+
"SFFHFFFH",
|
| 125 |
+
"FFFHFFFF",
|
| 126 |
+
"FFFFFFFF",
|
| 127 |
+
"FFFFFFFF",
|
| 128 |
+
"HFFFFFFF",
|
| 129 |
+
"HHFFFFHF",
|
| 130 |
+
"FFFFFHHF",
|
| 131 |
+
"FHFFFFFG",
|
| 132 |
+
],
|
| 133 |
+
]
|
| 134 |
+
# __END_curriculum_learning_example_env_options__
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
# Simple function sent to an EnvRunner to change the map of all its gym. Envs from
|
| 138 |
+
# the current one to a new (tougher) one, in which the goal position is further away
|
| 139 |
+
# from the starting position. Note that a map is a list of strings, each one
|
| 140 |
+
# representing one row in the map. Each character in the strings represent a single
|
| 141 |
+
# field (S=starting position, H=hole (bad), F=frozen/free field (ok), G=goal (great!)).
|
| 142 |
+
def _remote_fn(env_runner, new_task: int):
|
| 143 |
+
# We recreate the entire env object by changing the env_config on the worker,
|
| 144 |
+
# then calling its `make_env()` method.
|
| 145 |
+
env_runner.config.environment(env_config={"desc": ENV_MAPS[new_task]})
|
| 146 |
+
env_runner.make_env()
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
class EnvTaskCallback(RLlibCallback):
|
| 150 |
+
"""Custom callback implementing `on_train_result()` for changing the envs' maps."""
|
| 151 |
+
|
| 152 |
+
def on_train_result(
|
| 153 |
+
self,
|
| 154 |
+
*,
|
| 155 |
+
algorithm: Algorithm,
|
| 156 |
+
metrics_logger=None,
|
| 157 |
+
result: dict,
|
| 158 |
+
**kwargs,
|
| 159 |
+
) -> None:
|
| 160 |
+
# Hack: Store the current task inside a counter in our Algorithm.
|
| 161 |
+
# W/o a curriculum, the task is always 2 (hardest).
|
| 162 |
+
if args.no_curriculum:
|
| 163 |
+
algorithm._counters["current_env_task"] = 2
|
| 164 |
+
current_task = algorithm._counters["current_env_task"]
|
| 165 |
+
|
| 166 |
+
# If episode return is consistently `args.upgrade_task_threshold`, we switch
|
| 167 |
+
# to a more difficult task (if possible). If we already mastered the most
|
| 168 |
+
# difficult task, we publish our victory in the result dict.
|
| 169 |
+
result["task_solved"] = 0.0
|
| 170 |
+
current_return = result[ENV_RUNNER_RESULTS][EPISODE_RETURN_MEAN]
|
| 171 |
+
if current_return > args.upgrade_task_threshold:
|
| 172 |
+
if current_task < 2:
|
| 173 |
+
new_task = current_task + 1
|
| 174 |
+
print(
|
| 175 |
+
f"Switching task/map on all EnvRunners to #{new_task} (0=easiest, "
|
| 176 |
+
f"2=hardest), b/c R={current_return} on current task."
|
| 177 |
+
)
|
| 178 |
+
algorithm.env_runner_group.foreach_env_runner(
|
| 179 |
+
func=partial(_remote_fn, new_task=new_task)
|
| 180 |
+
)
|
| 181 |
+
algorithm._counters["current_env_task"] = new_task
|
| 182 |
+
|
| 183 |
+
# Hardest task was solved (1.0) -> report this in the results dict.
|
| 184 |
+
elif current_return == 1.0:
|
| 185 |
+
result["task_solved"] = 1.0
|
| 186 |
+
# Emergency brake: If return is 0.0 AND we are already at a harder task (1 or
|
| 187 |
+
# 2), we go back to task=0.
|
| 188 |
+
elif current_return == 0.0 and current_task > 0:
|
| 189 |
+
print(
|
| 190 |
+
"Emergency brake: Our policy seemed to have collapsed -> Setting task "
|
| 191 |
+
"back to 0."
|
| 192 |
+
)
|
| 193 |
+
algorithm.env_runner_group.foreach_env_runner(
|
| 194 |
+
func=partial(_remote_fn, new_task=0)
|
| 195 |
+
)
|
| 196 |
+
algorithm._counters["current_env_task"] = 0
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
if __name__ == "__main__":
|
| 200 |
+
args = parser.parse_args()
|
| 201 |
+
|
| 202 |
+
base_config = (
|
| 203 |
+
get_trainable_cls(args.algo)
|
| 204 |
+
.get_default_config()
|
| 205 |
+
# Plug in our curriculum callbacks that controls when we should upgrade the env
|
| 206 |
+
# task based on the received return for the current task.
|
| 207 |
+
.callbacks(EnvTaskCallback)
|
| 208 |
+
.environment(
|
| 209 |
+
"FrozenLake-v1",
|
| 210 |
+
env_config={
|
| 211 |
+
# w/ curriculum: start with task=0 (easiest)
|
| 212 |
+
# w/o curriculum: start directly with hardest task 2.
|
| 213 |
+
"desc": ENV_MAPS[2 if args.no_curriculum else 0],
|
| 214 |
+
**ENV_OPTIONS,
|
| 215 |
+
},
|
| 216 |
+
)
|
| 217 |
+
.env_runners(
|
| 218 |
+
num_envs_per_env_runner=5,
|
| 219 |
+
env_to_module_connector=lambda env: FlattenObservations(),
|
| 220 |
+
)
|
| 221 |
+
.training(
|
| 222 |
+
num_epochs=6,
|
| 223 |
+
vf_loss_coeff=0.01,
|
| 224 |
+
lr=0.0002,
|
| 225 |
+
)
|
| 226 |
+
.rl_module(model_config=DefaultModelConfig(vf_share_layers=True))
|
| 227 |
+
)
|
| 228 |
+
|
| 229 |
+
stop = {
|
| 230 |
+
TRAINING_ITERATION: args.stop_iters,
|
| 231 |
+
# Reward directly does not matter to us as we would like to continue
|
| 232 |
+
# after the policy reaches a return of ~1.0 on the 0-task (easiest).
|
| 233 |
+
# But we DO want to stop, once the entire task is learned (policy achieves
|
| 234 |
+
# return of 1.0 on the most difficult task=2).
|
| 235 |
+
"task_solved": 1.0,
|
| 236 |
+
NUM_ENV_STEPS_SAMPLED_LIFETIME: args.stop_timesteps,
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
run_rllib_example_script_experiment(
|
| 240 |
+
base_config, args, stop=stop, success_metric={"task_solved": 1.0}
|
| 241 |
+
)
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (196 Bytes). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/agents_act_in_sequence.cpython-311.pyc
ADDED
|
Binary file (3.68 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/agents_act_simultaneously.cpython-311.pyc
ADDED
|
Binary file (4.41 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/async_gym_env_vectorization.cpython-311.pyc
ADDED
|
Binary file (6.47 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/custom_env_render_method.cpython-311.pyc
ADDED
|
Binary file (9.29 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/custom_gym_env.cpython-311.pyc
ADDED
|
Binary file (6.46 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/env_connecting_to_rllib_w_tcp_client.cpython-311.pyc
ADDED
|
Binary file (5.72 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/env_rendering_and_recording.cpython-311.pyc
ADDED
|
Binary file (11.6 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/env_w_protobuf_observations.cpython-311.pyc
ADDED
|
Binary file (4 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/greyscale_env.cpython-311.pyc
ADDED
|
Binary file (5.26 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/__pycache__/unity3d_env_local.cpython-311.pyc
ADDED
|
Binary file (7.46 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (204 Bytes). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/action_mask_env.cpython-311.pyc
ADDED
|
Binary file (2.81 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/cartpole_crashing.cpython-311.pyc
ADDED
|
Binary file (8.34 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/cartpole_sparse_rewards.cpython-311.pyc
ADDED
|
Binary file (3.33 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/cartpole_with_dict_observation_space.cpython-311.pyc
ADDED
|
Binary file (4.36 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/cartpole_with_large_observation_space.cpython-311.pyc
ADDED
|
Binary file (4.61 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/cartpole_with_protobuf_observation_space.cpython-311.pyc
ADDED
|
Binary file (4.71 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/cliff_walking_wall_env.cpython-311.pyc
ADDED
|
Binary file (3.51 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/correlated_actions_env.cpython-311.pyc
ADDED
|
Binary file (4.24 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/d4rl_env.cpython-311.pyc
ADDED
|
Binary file (2.09 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/debug_counter_env.cpython-311.pyc
ADDED
|
Binary file (6.51 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/deterministic_envs.cpython-311.pyc
ADDED
|
Binary file (911 Bytes). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/dm_control_suite.cpython-311.pyc
ADDED
|
Binary file (2.48 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/env_using_remote_actor.cpython-311.pyc
ADDED
|
Binary file (3.5 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/env_with_subprocess.cpython-311.pyc
ADDED
|
Binary file (3.15 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/fast_image_env.cpython-311.pyc
ADDED
|
Binary file (1.66 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/gpu_requiring_env.cpython-311.pyc
ADDED
|
Binary file (2.31 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/look_and_push.cpython-311.pyc
ADDED
|
Binary file (4.24 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/memory_leaking_env.cpython-311.pyc
ADDED
|
Binary file (2.28 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/mock_env.cpython-311.pyc
ADDED
|
Binary file (14.5 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/nested_space_repeat_after_me_env.cpython-311.pyc
ADDED
|
Binary file (3.57 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/parametric_actions_cartpole.cpython-311.pyc
ADDED
|
Binary file (7.43 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/random_env.cpython-311.pyc
ADDED
|
Binary file (6.45 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/recommender_system_envs_with_recsim.cpython-311.pyc
ADDED
|
Binary file (4.17 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/repeat_after_me_env.cpython-311.pyc
ADDED
|
Binary file (3.09 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/repeat_initial_obs_env.cpython-311.pyc
ADDED
|
Binary file (1.92 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/simple_corridor.cpython-311.pyc
ADDED
|
Binary file (2.95 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/simple_rpg.cpython-311.pyc
ADDED
|
Binary file (2.65 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/six_room_env.cpython-311.pyc
ADDED
|
Binary file (10.9 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/stateless_cartpole.cpython-311.pyc
ADDED
|
Binary file (2.59 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/stateless_pendulum.cpython-311.pyc
ADDED
|
Binary file (2.46 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/transformed_action_space_env.cpython-311.pyc
ADDED
|
Binary file (3.46 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/ray/rllib/examples/envs/classes/__pycache__/windy_maze_env.cpython-311.pyc
ADDED
|
Binary file (8.71 kB). View file
|
|
|