!22050 fix dqn mean_reward error

Merge pull request !22050 from caojian05/ms_master_bugfix
This commit is contained in:
i-robot 2021-08-23 15:59:44 +00:00 committed by Gitee
commit 5c90bae35c
2 changed files with 3 additions and 3 deletions

View File

@ -118,5 +118,5 @@ class Agent:
q_next_numpy = q_next.asnumpy()
tem_ = Tensor(np.max(q_next_numpy, axis=1).reshape(-1, 1))
q_target = b_r + self.gamma * tem_
self.train_net(b_s, q_target, b_a)
loss = self.train_net(b_s, q_target, b_a)
return loss

View File

@ -88,7 +88,7 @@ if __name__ == "__main__":
agent.store_transition(s, a, r, s_)
ep_r += r
if agent.memory_counter > cfg.memory_capacity:
agent.learn()
_ = agent.learn()
if done_:
print("episode", episode, "total_reward", round(ep_r, 2))
rewards.append(round(ep_r, 2))