def __init__(self, task): self.task = task self.state_size = task.state_size self.action_size = task.action_size self.action_low = task.action_low self.action_high = task.action_high # Actor (Policy) Model self.actor_local = Actor(self.state_size, self.action_size, self.action_low, self.action_high) self.actor_target = Actor(self.state_size, self.action_size, self.action_low, self.action_high) # Critic (Value) Model self.critic_local = Critic(self.state_size, self.action_size) self.critic_target = Critic(self.state_size, self.action_size) # Initialize target model parameters with local model parameters self.critic_target.model.set_weights(self.critic_local.model.get_weights()) self.actor_target.model.set_weights(self.actor_local.model.get_weights()) # Noise process self.exploration_mu = 0 self.exploration_theta = 0.15 self.exploration_sigma = 0.2 self.noise = OUNoise(self.action_size, self.exploration_mu, self.exploration_theta, self.exploration_sigma) # Replay memory self.buffer_size = 100000 self.batch_size = 64 self.memory = ReplayBuffer(self.buffer_size, self.batch_size) # Algorithm parameters self.gamma = 0.90 # discount factor self.tau = 0.005 # for soft update of target parameters
def __init__(self, task): self.task = task self.state_size = task.state_size self.action_size = task.action_size # Exploration parameters self.decay_max = 1.0 # exploration probability at start self.decay_min = 0.01 # minimum exploration probability self.decay_rate = 0.0001 # exponential decay rate for exploration prob self.decay_step = np.exp(-self.decay_rate) self.decay_range = self.decay_max - self.decay_min self.decay_factor = 1. self.explore_p = self.decay_max # Network parameters self.learning_rate = 0.0001 # Q-network learning rate #self.learning_rate = 0.001 # Q-network learning rate # Replay memory self.buffer_size = 100000 self.batch_size = 64 self.memory = ReplayBuffer(self.buffer_size, self.batch_size) # Algorithm parameters self.gamma = 0.99 # discount factor # Score tracker and learning parameters self.best_score = -np.inf self.score = -np.inf self.loss = 0 self.qnet = QNetwork(self.state_size, self.action_size, name='main', learning_rate=self.learning_rate) # Episode variables self.reset_episode()
def __init__(self, cfg): # Environment configuration self.action_shape = cfg['env']['action_shape'] # Replay memory cfg['agent']['memory']['action_shape'] = self.action_shape self.memory = ReplayBuffer(**cfg['agent']['memory']) # Algorithm parameters self.exploration_mu, self.exploration_sigma = cfg['agent']['noise'] self.gamma = cfg['agent']['gamma'] self.tau = cfg['agent']['tau'] state_flatten_shape = [np.prod(self.memory.flatten_state_shape)] # Actor Model self.actor = Actor(state_flatten_shape, self.action_shape, cfg['env']['action_range'], self.tau, self.memory.batch_size, cfg['actor']) # Critic Model self.critic = Critic(state_flatten_shape, self.action_shape, self.tau, cfg['critic']) # Flag & Counter self.training = True self.episode = 0 self.max_episode_explore = cfg['agent']['explore']
def __init__(self, task): self.task = task self.state_size = task.state_size self.action_size = task.action_size self.action_low = task.action_low self.action_high = task.action_high # Actor (Policy) Model self.actor_local = Actor(self.state_size, self.action_size, self.action_low, self.action_high) self.actor_target = Actor(self.state_size, self.action_size, self.action_low, self.action_high) # Critic (Value) Model self.critic_local = Critic(self.state_size, self.action_size) self.critic_target = Critic(self.state_size, self.action_size) # Initialize target model parameters with local model parameters self.critic_target.model.set_weights( self.critic_local.model.get_weights()) self.actor_target.model.set_weights( self.actor_local.model.get_weights()) # Noise process self.exploration_mu = 0 self.exploration_theta = 0.15 self.exploration_sigma = 0.2 #self.exploration_mu = 0.0001 #self.exploration_theta = 0.2 #self.exploration_sigma = 0.25 self.noise = OUNoise(self.action_size, self.exploration_mu, self.exploration_theta, self.exploration_sigma) # Replay memory self.buffer_size = 100000 self.batch_size = 64 self.memory = ReplayBuffer(self.buffer_size, self.batch_size) # Algorithm parameters self.gamma = 0.99 # discount factor self.tau = 0.01 # for soft update of target parameters #self.tau = .005 self.closeCount = 0 # Score tracker ##################### self.best_score = -np.inf self.total_reward = 0.0 self.currentclose = 0
def __init__(self, task): self.task = task self.state_size = task.state_size self.action_size = task.action_size self.action_low = task.action_low self.action_high = task.action_high self.action_range = task.action_high - task.action_low # Actor (Policy) Model self.actor_local = Actor(self.state_size, self.action_size, self.action_low, self.action_high) self.actor_target = Actor(self.state_size, self.action_size, self.action_low, self.action_high) # Critic (Value) Model self.critic_local = Critic(self.state_size, self.action_size) self.critic_target = Critic(self.state_size, self.action_size) # Initialize target model parameters with local model parameters self.critic_target.model.set_weights( self.critic_local.model.get_weights()) self.actor_target.model.set_weights( self.actor_local.model.get_weights()) # Noise process self.exploration_mu = 0 self.exploration_theta = 0.001 self.exploration_sigma = 1 self.noise = OUNoise(self.action_size, self.exploration_mu, self.exploration_theta, self.exploration_sigma) # Replay memory self.buffer_size = 100000 self.batch_size = 64 self.memory = ReplayBuffer(self.buffer_size, self.batch_size) # Algorithm parameters self.gamma = 0.99 # discount factor self.tau = 0.05 # for soft update of target parameters # Score tracker and learning parameters self.best_score = -np.inf self.score = -np.inf # Episode variables self.reset_episode() self.noise.reset() self.noise.state = [100.] * self.action_size
def __init__(self, task, name, loadfile=False): self.task = task self.state_size = task.state_size self.action_size = task.action_size self.action_low = task.action_low self.action_high = task.action_high # Actor (Policy) Model self.actor_local = Actor(self.state_size, self.action_size, self.action_low, self.action_high) self.actor_target = Actor(self.state_size, self.action_size, self.action_low, self.action_high) # Critic (Value) Model self.critic_local = Critic(self.state_size, self.action_size) self.critic_target = Critic(self.state_size, self.action_size) self.name = name if loadfile: self.actor_local.model.load_weights("./weights/" + name + "_actor.h5") self.critic_local.model.load_weights("./weights/" + name + "_critic.h5") # Initialize target model parameters with local model parameters self.critic_target.model.set_weights( self.critic_local.model.get_weights()) self.actor_target.model.set_weights( self.actor_local.model.get_weights()) # Noise process self.exploration_mu = 0 self.exploration_theta = 0.15 #0.3 #original 0.15 self.exploration_sigma = 0.3 #0.3 #original 0.3 self.noise = OUNoise(self.action_size, self.exploration_mu, self.exploration_theta, self.exploration_sigma) # Replay memory self.buffer_size = 1000000 self.batch_size = 64 self.memory = ReplayBuffer(self.buffer_size, self.batch_size) # Algorithm parameters self.gamma = 0.99 # discount factor self.tau = 0.001 # for soft update of target parameters