Skip to content

Commit

Permalink
make obs batch require grads as requirement for loss
Browse files Browse the repository at this point in the history
  • Loading branch information
romaf5 committed Oct 29, 2024
1 parent 32c47df commit 633bd4c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rl_games/algos_torch/a2c_continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ def calc_gradients(self, input_dict):
lr_mul = 1.0
curr_e_clip = self.e_clip

# set requires_grad to True for gradient penalty loss
obs_batch = obs_batch.requires_grad_(True)

batch_dict = {
'is_train': True,
'prev_actions': actions_batch,
Expand Down
3 changes: 3 additions & 0 deletions rl_games/algos_torch/a2c_discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ def calc_gradients(self, input_dict):
lr_mul = 1.0
curr_e_clip = lr_mul * self.e_clip

# set requires_grad to True for gradient penalty loss
obs_batch = obs_batch.requires_grad_(True)

batch_dict = {
'is_train': True,
'prev_actions': actions_batch,
Expand Down

0 comments on commit 633bd4c

Please sign in to comment.