Skip to content

Commit

Permalink
Merge pull request #157 from zuoxingdong/add_ddpg2
Browse files Browse the repository at this point in the history
update CMA-ES
  • Loading branch information
zuoxingdong committed May 6, 2019
2 parents caf4c44 + 3f8182f commit 842ed32
Show file tree
Hide file tree
Showing 273 changed files with 13 additions and 7 deletions.
12 changes: 7 additions & 5 deletions baselines/cmaes/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
from lagom.envs.wrappers import VecStandardizeObservation

from lagom import CMAES
from agent import Agent
from .agent import Agent


config = Config(
{'cuda': False,
'log.dir': 'logs/default',
'log.freq': 10,
'checkpoint.freq': 50,
'checkpoint.num': 3,

'env.id': Grid(['HalfCheetah-v3', 'Hopper-v3', 'Walker2d-v3', 'Swimmer-v3']),
'env.standardize_obs': False,
Expand Down Expand Up @@ -70,7 +70,7 @@ def initializer(config, seed, device):
env = make_env(config, seed)
env = VecMonitor(env)
if config['env.standardize_obs']:
env = VecStandardizeObservation(env, clip=10.)
env = VecStandardizeObservation(env, clip=5.)
global agent
agent = Agent(config, env, device)

Expand Down Expand Up @@ -102,6 +102,7 @@ def run(config, seed, device):
{'popsize': config['train.popsize'],
'seed': seed})
train_logs = []
checkpoint_count = 0
with ProcessPoolExecutor(max_workers=config['train.popsize'], initializer=initializer, initargs=(config, seed, device)) as executor:
print('Finish initialization. Training starts...')
for generation in range(config['train.generations']):
Expand All @@ -119,9 +120,10 @@ def run(config, seed, device):
train_logs.append(logger.logs)
if generation == 0 or (generation+1)%config['log.freq'] == 0:
logger.dump(keys=None, index=0, indent=0, border='-'*50)
if generation == 0 or (generation+1)%config['checkpoint.freq'] == 0:
if (generation+1) >= int(config['train.generations']*(checkpoint_count/(config['checkpoint.num'] - 1))):
agent.from_vec(torch.from_numpy(es.result.xbest).float())
agent.checkpoint(logdir, generation+1)
checkpoint_count += 1
pickle_dump(obj=train_logs, f=logdir/'train_logs', ext='.pkl')
return None

Expand All @@ -130,4 +132,4 @@ def run(config, seed, device):
run_experiment(run=run,
config=config,
seeds=[1770966829, 1500925526, 2054191100],
num_worker=1)
num_worker=5)
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_1.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_100.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_1000.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_150.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_200.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_250.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_300.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_350.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_400.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_450.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_50.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_500.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_550.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_600.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_650.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_700.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_750.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_800.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_850.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_900.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/agent_950.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1500925526/train_logs.pkl
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_1.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_100.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_1000.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_150.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_200.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_250.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_300.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_350.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_400.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_450.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_50.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_500.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_550.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_600.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_650.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_700.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_750.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_800.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_850.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_900.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/agent_950.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/1770966829/train_logs.pkl
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_1.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_100.pth
Binary file not shown.
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_150.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_200.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_250.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_300.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_350.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_400.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_450.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_50.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_500.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_550.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_600.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_650.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_700.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_750.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_800.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_850.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_900.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/0/2054191100/agent_950.pth
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"initial_reset_timestamp": 1557150719.5950277, "timestamps": [1557150728.285389], "episode_lengths": [1000], "episode_rewards": [1557.79705245007], "episode_types": ["t", "t"]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"stats": "openaigym.episode_batch.0.1865711.stats.json", "videos": [["openaigym.video.0.1865711.video000000.mp4", "openaigym.video.0.1865711.video000000.meta.json"], ["openaigym.video.0.1865711.video000001.mp4", "openaigym.video.0.1865711.video000001.meta.json"]], "env_info": {"gym_version": "0.12.1", "env_id": "Hopper-v3"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"episode_id": 0, "content_type": "video/mp4", "encoder_version": {"backend": "ffmpeg", "version": "b'ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 the FFmpeg developers\\nbuilt with gcc 7 (Ubuntu 7.3.0-16ubuntu3)\\nconfiguration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared\\nlibavutil 55. 78.100 / 55. 78.100\\nlibavcodec 57.107.100 / 57.107.100\\nlibavformat 57. 83.100 / 57. 83.100\\nlibavdevice 57. 10.100 / 57. 10.100\\nlibavfilter 6.107.100 / 6.107.100\\nlibavresample 3. 7. 0 / 3. 7. 0\\nlibswscale 4. 8.100 / 4. 8.100\\nlibswresample 2. 9.100 / 2. 9.100\\nlibpostproc 54. 7.100 / 54. 7.100\\n'", "cmdline": ["ffmpeg", "-nostats", "-loglevel", "error", "-y", "-r", "125", "-f", "rawvideo", "-s:v", "500x500", "-pix_fmt", "rgb24", "-i", "-", "-vf", "scale=trunc(iw/2)*2:trunc(ih/2)*2", "-vcodec", "libx264", "-pix_fmt", "yuv420p", "/home/zuo/Code/tmp/lagom/baselines/cmaes/logs/default/1/1500925526/anim/openaigym.video.0.1865711.video000000.mp4"]}}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"episode_id": 1, "content_type": "video/mp4", "encoder_version": {"backend": "ffmpeg", "version": "b'ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 the FFmpeg developers\\nbuilt with gcc 7 (Ubuntu 7.3.0-16ubuntu3)\\nconfiguration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared\\nlibavutil 55. 78.100 / 55. 78.100\\nlibavcodec 57.107.100 / 57.107.100\\nlibavformat 57. 83.100 / 57. 83.100\\nlibavdevice 57. 10.100 / 57. 10.100\\nlibavfilter 6.107.100 / 6.107.100\\nlibavresample 3. 7. 0 / 3. 7. 0\\nlibswscale 4. 8.100 / 4. 8.100\\nlibswresample 2. 9.100 / 2. 9.100\\nlibpostproc 54. 7.100 / 54. 7.100\\n'", "cmdline": ["ffmpeg", "-nostats", "-loglevel", "error", "-y", "-r", "125", "-f", "rawvideo", "-s:v", "500x500", "-pix_fmt", "rgb24", "-i", "-", "-vf", "scale=trunc(iw/2)*2:trunc(ih/2)*2", "-vcodec", "libx264", "-pix_fmt", "yuv420p", "/home/zuo/Code/tmp/lagom/baselines/cmaes/logs/default/1/1500925526/anim/openaigym.video.0.1865711.video000001.mp4"]}}
Binary file not shown.
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_1.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_100.pth
Binary file not shown.
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_150.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_200.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_250.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_300.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_350.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_400.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_450.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_50.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_500.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_550.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_600.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_650.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_700.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_750.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_800.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_850.pth
Binary file not shown.
Binary file modified baselines/cmaes/logs/default/1/1770966829/agent_900.pth
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added baselines/cmaes/logs/default/result.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions baselines/cmaes/logs/default/source_files/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def run(config, seed, device):
for generation in range(config['train.generations']):
start_time = time.perf_counter()
solutions = es.ask()
out = list(executor.map(fitness, solutions))
out = list(executor.map(fitness, solutions, chunksize=4))
Rs, Hs = zip(*out)
es.tell(solutions, [-R for R in Rs])
logger = Logger()
Expand All @@ -130,4 +130,4 @@ def run(config, seed, device):
run_experiment(run=run,
config=config,
seeds=[1770966829, 1500925526, 2054191100],
num_worker=2)
num_worker=1)

0 comments on commit 842ed32

Please sign in to comment.