Refactor LL buffer
This commit is contained in:
@@ -11,4 +11,5 @@
|
|||||||
#python -m expert --env=NRasterizedRouteRandomAgentLocation --min_timesteps=100000 --env_args='{width:70,height:70,m_per_px:1,map_color:128}' --policy_args='{mu:0.001}' --path='NormalizedIntersimpleExpertMu.001N100000_NRasterizedRouteRandomAgentLocationw70h70mppx1mapc128.pkl'
|
#python -m expert --env=NRasterizedRouteRandomAgentLocation --min_timesteps=100000 --env_args='{width:70,height:70,m_per_px:1,map_color:128}' --policy_args='{mu:0.001}' --path='NormalizedIntersimpleExpertMu.001N100000_NRasterizedRouteRandomAgentLocationw70h70mppx1mapc128.pkl'
|
||||||
#python -m expert --env=NRasterizedRouteSpeedRandomAgentLocation --min_timesteps=10000 --env_args='{width:70,height:70,m_per_px:1,map_color:128,mu:0.001}' --policy_args='{mu:0.001}' --path='NormalizedIntersimpleExpertMu.001N10000_NRasterizedRouteSpeedRandomAgentLocationw70h70mppx1mapc128mu.001.pkl'
|
#python -m expert --env=NRasterizedRouteSpeedRandomAgentLocation --min_timesteps=10000 --env_args='{width:70,height:70,m_per_px:1,map_color:128,mu:0.001}' --policy_args='{mu:0.001}' --path='NormalizedIntersimpleExpertMu.001N10000_NRasterizedRouteSpeedRandomAgentLocationw70h70mppx1mapc128mu.001.pkl'
|
||||||
#python -m data.expert --env=NRasterizedRouteSpeedRandomAgentLocation --min_timesteps=10000 --env_args='{width:70,height:70,m_per_px:1,map_color:128,mu:0.001,skip_frames:5}' --policy_args='{mu:0.001}' --path='NormalizedIntersimpleExpertMu.001N10000_NRasterizedRouteSpeedRandomAgentLocationw70h70mppx1mapc128mu.001skip5.pkl'
|
#python -m data.expert --env=NRasterizedRouteSpeedRandomAgentLocation --min_timesteps=10000 --env_args='{width:70,height:70,m_per_px:1,map_color:128,mu:0.001,skip_frames:5}' --policy_args='{mu:0.001}' --path='NormalizedIntersimpleExpertMu.001N10000_NRasterizedRouteSpeedRandomAgentLocationw70h70mppx1mapc128mu.001skip5.pkl'
|
||||||
python -m data.expert --env=TLNRasterizedRouteRandomAgentLocation --min_timesteps=100000 --env_args='{width:70,height:70,m_per_px:1,mu:0.001,random_skip:True,max_episode_steps:50}' --policy_args='{mu:0.001}' --path='NormalizedIntersimpleExpertMu.001N100000_TLNRasterizedRouteRandomAgentLocationw70h70mppx1mu.001rskips50.pkl'
|
#python -m data.expert --env=TLNRasterizedRouteRandomAgentLocation --min_timesteps=100000 --env_args='{width:70,height:70,m_per_px:1,mu:0.001,random_skip:True,max_episode_steps:50}' --policy_args='{mu:0.001}' --path='NormalizedIntersimpleExpertMu.001N100000_TLNRasterizedRouteRandomAgentLocationw70h70mppx1mu.001rskips50.pkl'
|
||||||
|
python -m data.expert --env=TLNRasterizedRouteRandomAgentLocation --min_timesteps=50000 --env_args='{width:70,height:70,m_per_px:1,mu:0.001,random_skip:True,max_episode_steps:50}' --policy_args='{mu:0.001}' --path='NormalizedIntersimpleExpertMu.001N50000_TLNRasterizedRouteRandomAgentLocationw70h70mppx1mu.001rskips50.pkl'
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ def imitation_discriminator(discriminator):
|
|||||||
|
|
||||||
class OptionsEnv(gym.Wrapper):
|
class OptionsEnv(gym.Wrapper):
|
||||||
|
|
||||||
def __init__(self, env, options, discriminator, discount, ll_buffer_capacity, *args, **kwargs):
|
def __init__(self, env, options, discriminator, discount, ll_buffer, *args, **kwargs):
|
||||||
super().__init__(env, *args, **kwargs)
|
super().__init__(env, *args, **kwargs)
|
||||||
|
|
||||||
self.options = options
|
self.options = options
|
||||||
@@ -27,8 +27,7 @@ class OptionsEnv(gym.Wrapper):
|
|||||||
|
|
||||||
self.discriminator = discriminator
|
self.discriminator = discriminator
|
||||||
self.discount = discount
|
self.discount = discount
|
||||||
self.ll_buffer_capacity = ll_buffer_capacity
|
self.ll_buffer = ll_buffer
|
||||||
self.ll_buffer = deque(maxlen=ll_buffer_capacity)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _hl_observation(obs, mask):
|
def _hl_observation(obs, mask):
|
||||||
@@ -78,16 +77,10 @@ class OptionsEnv(gym.Wrapper):
|
|||||||
|
|
||||||
return self._hl_observation(self.obs, self.m), reward, self.done, info
|
return self._hl_observation(self.obs, self.m), reward, self.done, info
|
||||||
|
|
||||||
def sample_ll(self, n):
|
|
||||||
assert n <= self.ll_buffer_capacity, f'Sample size of {n} exceeds buffer capacity of {self.ll_buffer_capacity}'
|
|
||||||
assert n <= len(self.ll_buffer), f'Sample size of {n} exceeds buffer size of {len(self.ll_buffer)}'
|
|
||||||
ind = np.random.randint(len(self.ll_buffer), size=n)
|
|
||||||
return list(self.ll_buffer[i] for i in ind)
|
|
||||||
|
|
||||||
class RenderOptions(OptionsEnv):
|
class RenderOptions(OptionsEnv):
|
||||||
|
|
||||||
def __init__(self, env, options, *args, **kwargs):
|
def __init__(self, env, options, *args, **kwargs):
|
||||||
super().__init__(env, options, discriminator=lambda s, a, n, d: 0, discount=1, ll_buffer_capacity=0, *args, **kwargs)
|
super().__init__(env, options, discriminator=lambda s, a, n, d: 0, discount=1, ll_buffer=deque(maxlen=0), *args, **kwargs)
|
||||||
|
|
||||||
def _ll_step(self, action):
|
def _ll_step(self, action):
|
||||||
out = super()._ll_step(action)
|
out = super()._ll_step(action)
|
||||||
|
|||||||
Reference in New Issue
Block a user