From 93a5c3fc042ffdb7cc2e942ef81b11b2e9691443 Mon Sep 17 00:00:00 2001 From: Shangtong Zhang Date: Fri, 18 May 2018 14:24:45 -0600 Subject: [PATCH] Minor update --- deep_rl/network/network_utils.py | 1 + examples.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/deep_rl/network/network_utils.py b/deep_rl/network/network_utils.py index a0d303c..9ddafce 100644 --- a/deep_rl/network/network_utils.py +++ b/deep_rl/network/network_utils.py @@ -12,6 +12,7 @@ import numpy as np class BaseNet: def set_gpu(self, gpu): if gpu >= 0 and torch.cuda.is_available(): + gpu = gpu % torch.cuda.device_count() self.device = torch.device('cuda:%d' % (gpu)) else: self.device = torch.device('cpu') diff --git a/examples.py b/examples.py index 9a41ee8..2d23f3b 100644 --- a/examples.py +++ b/examples.py @@ -363,7 +363,7 @@ def ddpg_low_dim_state(): def ddpg_pixel(): config = Config() log_dir = get_default_log_dir(ddpg_pixel.__name__) - task_fn = lambda **kwargs: PixelBullet('AntBulletEnv-v0', frame_skip=1, **kwargs) + task_fn = lambda **kwargs: PixelBullet('AntBulletEnv-v0', frame_skip=4, **kwargs) # each bullet environment should be started in a new process, it is a workaround # to the issue of self-collision @@ -373,11 +373,11 @@ def ddpg_pixel(): phi_body=NatureConvBody() config.network_fn = lambda state_dim, action_dim: DeterministicActorCriticNet( - state_dim, action_dim, phi_body=NatureConvBody(), + state_dim, action_dim, phi_body=phi_body, actor_body=FCBody(phi_body.feature_dim, (200, 200), gate=F.relu), critic_body=TwoLayerFCBodyWithAction(phi_body.feature_dim, action_dim, (200, 200), gate=F.relu), actor_opt_fn=lambda params: torch.optim.Adam(params, lr=1e-4), - critic_opt_fn=lambda params: torch.optim.Adam(params, lr=1e-3), gpu=1) + critic_opt_fn=lambda params: torch.optim.Adam(params, lr=1e-3), gpu=0) config.replay_fn = lambda: Replay(memory_size=1000000, batch_size=64) config.discount = 0.99 @@ -443,7 +443,7 @@ if __name__ == '__main__': # dqn_ram_atari('Breakout-ramNoFrameskip-v4') # ddpg_low_dim_state() - # ddpg_pixel() + ddpg_pixel() # ppo_continuous() # action_conditional_video_prediction()