Skip to content

Commit

Permalink
refactor(ppo): optimize early stopping with for-else loop
Browse files Browse the repository at this point in the history
   - Replace dual break checks with Pythonic for-else structure
   - Improve code readability while maintaining original logic
   - Related to issue haosulab#830
  • Loading branch information
songyuc committed Feb 10, 2025
1 parent 4f91172 commit b0dba90
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/baselines/ppo/ppo.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ def clip_action(action: torch.Tensor):
loss.backward()
nn.utils.clip_grad_norm_(agent.parameters(), args.max_grad_norm)
optimizer.step()

if args.target_kl is not None and approx_kl > args.target_kl:
break
else:
continue
break

update_time = time.time() - update_time

Expand Down

0 comments on commit b0dba90

Please sign in to comment.