mirror of
https://github.com/wassname/DeepRL.git
synced 2026-09-09 11:13:47 +08:00
Major update
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user