Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug in gradient clipping of deepq_learner (tf2 branch) #1207

Open
Giullar opened this issue Nov 9, 2022 · 1 comment
Open

Possible bug in gradient clipping of deepq_learner (tf2 branch) #1207

Giullar opened this issue Nov 9, 2022 · 1 comment

Comments

@Giullar
Copy link

Giullar commented Nov 9, 2022

grads = tape.gradient(weighted_error, self.q_network.trainable_variables)
if self.grad_norm_clipping:
clipped_grads = []
for grad in grads:
clipped_grads.append(tf.clip_by_norm(grad, self.grad_norm_clipping))
clipped_grads = grads
grads_and_vars = zip(grads, self.q_network.trainable_variables)
self.optimizer.apply_gradients(grads_and_vars)

In line 179, shouldn't it be:
grads = clipped_grads
instead of
clipped_grads = grads
?

@Giullar Giullar changed the title Possible bug in gradient clipping of deepq_learner Possible bug in gradient clipping of deepq_learner (tf2 branch) Nov 10, 2022
@susanth-24
Copy link

yes, I think you are right. It should be grads = clipped_grads, as it is the list containing the gradients after clipping, which should be used for optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants