diff --git a/robustified/gen_demo/new_gen_demo.py b/robustified/gen_demo/new_gen_demo.py index fb3202b..4a123b5 100644 --- a/robustified/gen_demo/new_gen_demo.py +++ b/robustified/gen_demo/new_gen_demo.py @@ -3,7 +3,7 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. @@ -14,11 +14,11 @@ import gzip import bz2 from PIL import Image, ImageFont, ImageDraw -import gen_demo.atari_demo as atari_demo -import gen_demo.atari_demo.wrappers +import atari_demo as atari_demo +import atari_demo.wrappers -from goexplore_py.goexplore import * -import goexplore_py.complex_fetch_env +from goexplore import * +import complex_fetch_env import cv2 from tqdm import tqdm diff --git a/robustified/gen_demo_atari.sh b/robustified/gen_demo_atari.sh index 846720c..b959d40 100755 --- a/robustified/gen_demo_atari.sh +++ b/robustified/gen_demo_atari.sh @@ -4,7 +4,7 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. @@ -15,5 +15,4 @@ source=$1 dest=${2:-`echo $source | sed -E 's/\/*$//'`_demo} game=${3:-MontezumaRevenge} -python gen_demo/new_gen_demo.py --source $source --destination=$dest --game=$game --select_done --n_demos=1 --compress=bz2 --min_compute_steps=0 $4 - +python3.6 gen_demo/new_gen_demo.py --source $source --destination=$dest --game=$game --select_done --n_demos=1 --compress=bz2 --min_compute_steps=0 $4 diff --git a/robustified/goexplore_py/complex_fetch_env.py b/robustified/goexplore_py/complex_fetch_env.py index 02669b9..66bae7f 100644 --- a/robustified/goexplore_py/complex_fetch_env.py +++ b/robustified/goexplore_py/complex_fetch_env.py @@ -3,13 +3,13 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. -from .import_ai import * +from import_ai import * import types os.environ["PATH"] = os.environ["PATH"].replace('/usr/local/nvidia/bin', '') diff --git a/robustified/goexplore_py/explorers.py b/robustified/goexplore_py/explorers.py index 17a7133..d53ab5a 100644 --- a/robustified/goexplore_py/explorers.py +++ b/robustified/goexplore_py/explorers.py @@ -3,13 +3,13 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. -from .import_ai import * +from import_ai import * class RandomExplorer: def init_seed(self): diff --git a/robustified/goexplore_py/generic_atari_env.py b/robustified/goexplore_py/generic_atari_env.py index b1bc759..b8141ed 100644 --- a/robustified/goexplore_py/generic_atari_env.py +++ b/robustified/goexplore_py/generic_atari_env.py @@ -3,16 +3,16 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. -from .basics import * -from .import_ai import * -from . import montezuma_env -from .utils import imdownscale +from basics import * +from import_ai import * +import montezuma_env +from utils import imdownscale def convert_state(state): if MyAtari.TARGET_SHAPE is None: diff --git a/robustified/goexplore_py/generic_goal_conditioned_env.py b/robustified/goexplore_py/generic_goal_conditioned_env.py index 8e142b3..fca4dc7 100644 --- a/robustified/goexplore_py/generic_goal_conditioned_env.py +++ b/robustified/goexplore_py/generic_goal_conditioned_env.py @@ -3,13 +3,13 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. -from .import_ai import * +from import_ai import * import types @@ -205,4 +205,4 @@ class MyRobot: def render_with_known(self, known_positions, resolution, show=True, filename=None, combine_val=max, get_val=lambda x: x.score, minmax=None): - pass \ No newline at end of file + pass diff --git a/robustified/goexplore_py/goexplore.py b/robustified/goexplore_py/goexplore.py index 7cf16a5..6e995d5 100644 --- a/robustified/goexplore_py/goexplore.py +++ b/robustified/goexplore_py/goexplore.py @@ -3,16 +3,16 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. -from .explorers import * -from .montezuma_env import * -from .generic_atari_env import * -from .utils import * +from explorers import * +from montezuma_env import * +from generic_atari_env import * +from utils import * import loky import gzip import bz2 diff --git a/robustified/goexplore_py/import_ai.py b/robustified/goexplore_py/import_ai.py index 4b7d830..258cacc 100644 --- a/robustified/goexplore_py/import_ai.py +++ b/robustified/goexplore_py/import_ai.py @@ -3,7 +3,7 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. @@ -19,12 +19,12 @@ def is_notebook(): except: return False return True - + if not is_notebook(): import matplotlib matplotlib.use('Agg') - -from .basics import * + +from basics import * import warnings as _warnings # Known to be benign: https://github.com/ContinuumIO/anaconda-issues/issues/6678#issuecomment-337279157 @@ -34,7 +34,7 @@ try: import cv2 except ModuleNotFoundError: _warnings.warn('cv2 not found') - + try: import gym except ModuleNotFoundError: @@ -158,7 +158,7 @@ class IgnoreNoHandles(logging.Filter): _plt_logger = logging.getLogger('matplotlib.legend') _plt_logger.addFilter(IgnoreNoHandles()) - + import matplotlib.pyplot as plt import numpy as np @@ -210,4 +210,3 @@ class CircularMemory: def __getitem__(self, i): assert i < len(self) return self.mem[(self.start_idx + i) % self.size] - diff --git a/robustified/goexplore_py/main.py b/robustified/goexplore_py/main.py index 48d419b..0495835 100644 --- a/robustified/goexplore_py/main.py +++ b/robustified/goexplore_py/main.py @@ -3,7 +3,7 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. @@ -11,14 +11,14 @@ import sys from sys import platform -from goexplore_py.randselectors import * -from goexplore_py.goexplore import * -import goexplore_py.goexplore -import goexplore_py.montezuma_env as montezuma_env -import goexplore_py.pitfall_env as pitfall_env -import goexplore_py.generic_atari_env as generic_atari_env -import goexplore_py.generic_goal_conditioned_env as generic_goal_conditioned_env -import goexplore_py.complex_fetch_env as complex_fetch_env +from randselectors import * +from goexplore import * +import goexplore +import montezuma_env as montezuma_env +import pitfall_env as pitfall_env +import generic_atari_env as generic_atari_env +import generic_goal_conditioned_env as generic_goal_conditioned_env +import complex_fetch_env as complex_fetch_env import cProfile import gzip @@ -61,8 +61,8 @@ def _run( args ): - goexplore_py.goexplore.perf_array = multiprocessing.Array('d', [0.0] * MemInfo.ARRAY_SIZE) - perf_process = multiprocessing.Process(target=track_performance, args=(goexplore_py.goexplore.perf_array, 1, 0.1)) + goexplore.perf_array = multiprocessing.Array('d', [0.0] * MemInfo.ARRAY_SIZE) + perf_process = multiprocessing.Process(target=track_performance, args=(goexplore.perf_array, 1, 0.1)) perf_process.start() if 'robot' in args.game: @@ -422,7 +422,7 @@ class Tee(object): self.stdout.write(data) def flush(self): self.file.flush() - + def run(base_path, args): cur_id = 0 if os.path.exists(base_path): @@ -476,13 +476,16 @@ def run(base_path, args): del info['base_path'] json.dump(info, open(base_path + '/kwargs.json', 'w'), sort_keys=True, indent=2) - code_path = base_path + '/code' + code_path = base_path + 'code' cur_dir = os.path.dirname(os.path.realpath(__file__)) - shutil.copytree(cur_dir, code_path, ignore=shutil.ignore_patterns('*.png', '*.stl', '*.JPG', '__pycache__', 'LICENSE*', 'README*')) + print(cur_dir) + print(code_path) + #exit() + shutil.copytree(cur_dir, code_path, ignore=shutil.ignore_patterns('*.png', '*.stl', '*.JPG', '__pycache__', 'LICENSE*', 'README*','results')) teeout = Tee(args.base_path + '/log.out', 'stdout') teeerr = Tee(args.base_path + '/log.err', 'stderr') - + print('Experiment running in', base_path) try: diff --git a/robustified/goexplore_py/montezuma_env.py b/robustified/goexplore_py/montezuma_env.py index 4f7193b..e34747f 100644 --- a/robustified/goexplore_py/montezuma_env.py +++ b/robustified/goexplore_py/montezuma_env.py @@ -3,14 +3,14 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. -from .import_ai import * -from .utils import imdownscale +from import_ai import * +from utils import imdownscale class MontezumaPosLevel: diff --git a/robustified/goexplore_py/pitfall_env.py b/robustified/goexplore_py/pitfall_env.py index 245eaff..4a99b80 100644 --- a/robustified/goexplore_py/pitfall_env.py +++ b/robustified/goexplore_py/pitfall_env.py @@ -3,14 +3,14 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. -from .import_ai import * -from .utils import imdownscale +from import_ai import * +from utils import imdownscale class PitfallPosLevel: diff --git a/robustified/goexplore_py/randselectors.py b/robustified/goexplore_py/randselectors.py index 813c98d..3bb954a 100644 --- a/robustified/goexplore_py/randselectors.py +++ b/robustified/goexplore_py/randselectors.py @@ -3,17 +3,17 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. -from .import_ai import * +from import_ai import * # from montezuma_env import * -from goexplore_py.complex_fetch_env import * -from goexplore_py.goexplore import DONE +from complex_fetch_env import * +from goexplore import DONE @dataclass() diff --git a/robustified/goexplore_py/utils.py b/robustified/goexplore_py/utils.py index a086392..a58f40f 100644 --- a/robustified/goexplore_py/utils.py +++ b/robustified/goexplore_py/utils.py @@ -3,13 +3,13 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. -from .import_ai import * +from import_ai import * class TimedPickle: def __init__(self, data, name, enabled=True): diff --git a/robustified/phase1_downscaled.sh b/robustified/phase1_downscaled.sh index cfa4b99..9feff33 100755 --- a/robustified/phase1_downscaled.sh +++ b/robustified/phase1_downscaled.sh @@ -4,7 +4,7 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. @@ -15,4 +15,4 @@ game=${1:-MontezumaRevenge} results=${2:-results} frames=${3:-500000000} -python goexplore_py/main.py --seen_weight=1.0 --reset_cell_on_update --base_path=$results --game=generic_$game --cell_split_factor=0.125 --first_compute_archive_size=1 --first_compute_dynamic_state=10000 --max_archive_size=50000 --max_recent_frames=10000 --recent_frame_add_prob=0.01 --recompute_dynamic_state_every=10000000 --split_iterations=3000 --state_is_pixels --high_score_weight=0.0 --max_hours=256 --max_compute_steps=$frames --n_cpus=88 --batch_size=100 --dynamic_state +python3.6 goexplore_py/main.py --seen_weight=1.0 --reset_cell_on_update --base_path=$results --game=generic_$game --cell_split_factor=0.125 --first_compute_archive_size=1 --first_compute_dynamic_state=10000 --max_archive_size=50000 --max_recent_frames=10000 --recent_frame_add_prob=0.01 --recompute_dynamic_state_every=10000000 --split_iterations=3000 --state_is_pixels --high_score_weight=0.0 --max_hours=256 --max_compute_steps=$frames --n_cpus=88 --batch_size=100 --dynamic_state diff --git a/robustified/phase2_atari.sh b/robustified/phase2_atari.sh index dc60d9a..d0f3d23 100755 --- a/robustified/phase2_atari.sh +++ b/robustified/phase2_atari.sh @@ -4,7 +4,7 @@ # Licensed under the Uber Non-Commercial License (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at the root directory of this project. +# You may obtain a copy of the License at the root directory of this project. # See the License for the specific language governing permissions and # limitations under the License. @@ -16,4 +16,4 @@ demo=${2:-`pwd`/demos} results=${3:-`pwd`/results} frames=${4:-2500000000} -python atari_reset/train_atari.py --game=$game --sil_vf_coef=0.01 --demo_selection=normalize_by_target --ent_coef=1e-05 --sil_ent_coef=1e-05 --n_sil_envs=2 --extra_sil_from_start_prob=0.3 --autoscale_fn=mean --sil_coef=0.1 --gamma=0.999 --move_threshold=0.1 --autoscale=10 --from_start_demo_reward_interval_factor=20000000 --nrstartsteps=160 --sil_pg_weight_by_value --sil_weight_success_rate --sil_vf_relu --sticky --noops --max_demo_len=400000 --autoscale_fn=mean --num_timesteps=$frames --autoscale_value --nenvs=32 --demo=$demo --no_game_over_on_life_loss --test_from_start --steps_per_demo=200 --no_videos --save_path=$results +python3.6 atari_reset/train_atari.py --game=$game --sil_vf_coef=0.01 --demo_selection=normalize_by_target --ent_coef=1e-05 --sil_ent_coef=1e-05 --n_sil_envs=2 --extra_sil_from_start_prob=0.3 --autoscale_fn=mean --sil_coef=0.1 --gamma=0.999 --move_threshold=0.1 --autoscale=10 --from_start_demo_reward_interval_factor=20000000 --nrstartsteps=160 --sil_pg_weight_by_value --sil_weight_success_rate --sil_vf_relu --sticky --noops --max_demo_len=400000 --autoscale_fn=mean --num_timesteps=$frames --autoscale_value --nenvs=32 --demo=$demo --no_game_over_on_life_loss --test_from_start --steps_per_demo=200 --no_videos --save_path=$results