From c98f42359245c2e44d4dd0c516e09be399134593 Mon Sep 17 00:00:00 2001 From: jdv Date: Thu, 30 Nov 2023 10:10:22 -0500 Subject: [PATCH] gradient clipping added back in --- tutorials/examples/train_line.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tutorials/examples/train_line.py b/tutorials/examples/train_line.py index 4e69c4ee..ccbbf1cf 100644 --- a/tutorials/examples/train_line.py +++ b/tutorials/examples/train_line.py @@ -236,11 +236,11 @@ def train( loss.backward() # Gradient Clipping. - # for p in gflownet.parameters(): - # if p.ndim > 0 and p.grad is not None: # We do not clip logZ grad. - # p.grad.data.clamp_( - # -gradient_clip_value, gradient_clip_value - # ).nan_to_num_(0.0) + for p in gflownet.parameters(): + if p.ndim > 0 and p.grad is not None: # We do not clip logZ grad. + p.grad.data.clamp_( + -gradient_clip_value, gradient_clip_value + ).nan_to_num_(0.0) optimizer.step() states_visited += len(trajectories)