Major update

This commit is contained in:
Shangtong Zhang
2017-10-06 22:10:44 -06:00
parent 8189a5d136
commit fae9a85f31
15 changed files with 136 additions and 150 deletions
+2 -2
View File
@@ -24,11 +24,11 @@ class AdvantageActorCritic:
steps = 0
total_reward = 0
pending = []
while not config.stop_signal.value and \
(not config.max_episode_length or steps < config.max_episode_length):
while not config.stop_signal.value:
prob, log_prob, value = self.worker_network.predict(np.stack([state]))
action = self.policy.sample(prob.data.numpy().flatten(), deterministic)
next_state, reward, terminal, _ = self.task.step(action)
terminal = (terminal or (self.config.max_episode_length and steps > self.config.max_episode_length))
steps += 1
total_reward += reward
+2 -2
View File
@@ -25,11 +25,11 @@ class NStepQLearning:
steps = 0
total_reward = 0
pending = []
while not config.stop_signal.value and \
(not config.max_episode_length or steps < config.max_episode_length):
while not config.stop_signal.value:
q = self.worker_network.predict(np.stack([state]))
action = self.policy.sample(q.data.numpy().flatten(), deterministic)
next_state, reward, terminal, _ = self.task.step(action)
terminal = (terminal or (config.max_episode_length and steps >= config.max_episode_length))
steps += 1
total_reward += reward
+2 -2
View File
@@ -25,11 +25,11 @@ class OneStepQLearning:
steps = 0
total_reward = 0
pending = []
while not config.stop_signal.value and \
(not config.max_episode_length or steps < config.max_episode_length):
while not config.stop_signal.value:
q = self.worker_network.predict(np.stack([state]))
action = self.policy.sample(q.data.numpy().flatten(), deterministic)
next_state, reward, terminal, _ = self.task.step(action)
terminal = (terminal or (config.max_episode_length and steps >= config.max_episode_length))
steps += 1
total_reward += reward
+2 -2
View File
@@ -27,9 +27,9 @@ class OneStepSarsa:
steps = 0
total_reward = 0
pending = []
while not config.stop_signal.value and \
(not config.max_episode_length or steps < config.max_episode_length):
while not config.stop_signal.value:
next_state, reward, terminal, _ = self.task.step(action)
terminal = (terminal or (config.max_episode_length and steps >= config.max_episode_length))
next_q = self.worker_network.predict(np.stack([next_state]))
next_action = self.policy.sample(next_q.data.numpy().flatten(), deterministic)
pending.append([q, action, reward, next_state, next_action])