Skip to content

Commit

Permalink
Use Link.cleargrads instead of Link.zerograds
Browse files Browse the repository at this point in the history
as zerograds is deprecated by Chainer
  • Loading branch information
muupan committed Aug 25, 2019
1 parent cc0f376 commit 640ea0d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chainerrl/agents/reinforce.py
Expand Up @@ -140,7 +140,7 @@ def stop_episode_and_train(self, obs, reward, done=False):

def accumulate_grad(self):
if self.n_backward == 0:
self.model.zerograds()
self.model.cleargrads()
# Compute losses
losses = []
for r_seq, log_prob_seq, ent_seq in zip(self.reward_sequences,
Expand Down Expand Up @@ -168,7 +168,7 @@ def batch_update(self):
assert len(self.log_prob_sequences) == self.batchsize
assert len(self.entropy_sequences) == self.batchsize
# Update the model
self.model.zerograds()
assert self.n_backward == 0
self.accumulate_grad()
self.optimizer.update()
self.n_backward = 0
Expand Down

0 comments on commit 640ea0d

Please sign in to comment.