mirror of
https://github.com/wassname/DeepRL.git
synced 2026-10-29 12:40:58 +08:00
Code cleanup
This commit is contained in:
1 parent
ceaf83bca3
commit
797f80d5ff
13 files changed
+87
-194
No files matched your search
@@ -29,7 +29,6 @@ class AdvantageActorCritic:
|
||||
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
|
||||
|
||||
@@ -43,7 +43,6 @@ class ContinuousAdvantageActorCritic:
|
||||
False)
|
||||
action = self.config.action_shift_fn(action)
|
||||
next_state, reward, terminal, _ = self.task.step(action)
|
||||
terminal = (terminal or (config.max_episode_length and steps >= config.max_episode_length))
|
||||
next_state = self.state_normalizer(next_state)
|
||||
|
||||
steps += 1
|
||||
|
||||
@@ -58,7 +58,6 @@ class DeterministicPolicyGradient:
|
||||
if not deterministic:
|
||||
action += self.random_process.sample()
|
||||
next_state, reward, done, info = self.task.step(action)
|
||||
done = (done or (config.max_episode_length and steps >= config.max_episode_length))
|
||||
next_state = self.state_normalizer(next_state)
|
||||
total_reward += reward
|
||||
reward = self.reward_normalizer(reward)
|
||||
|
||||
@@ -30,7 +30,6 @@ class NStepQLearning:
|
||||
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
|
||||
|
||||
@@ -30,7 +30,6 @@ class OneStepQLearning:
|
||||
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
|
||||
|
||||
@@ -30,7 +30,6 @@ class OneStepSarsa:
|
||||
pending = []
|
||||
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])
|
||||
|
||||
@@ -72,7 +72,6 @@ class ProximalPolicyOptimization:
|
||||
values.append(value)
|
||||
state, reward, done, _ = self.task.step(action)
|
||||
state = self.state_normalizer(state)
|
||||
done = (done or (config.max_episode_length and episode_length > config.max_episode_length))
|
||||
|
||||
batched_rewards += reward
|
||||
batched_steps += 1
|
||||
|
||||
Reference in new issue
Block a user