Skip to content

Commit b0dba90

Browse files
committed
refactor(ppo): optimize early stopping with for-else loop
- Replace dual break checks with Pythonic for-else structure - Improve code readability while maintaining original logic - Related to issue haosulab#830
1 parent 4f91172 commit b0dba90

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

examples/baselines/ppo/ppo.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,9 @@ def clip_action(action: torch.Tensor):
436436
loss.backward()
437437
nn.utils.clip_grad_norm_(agent.parameters(), args.max_grad_norm)
438438
optimizer.step()
439-
440-
if args.target_kl is not None and approx_kl > args.target_kl:
441-
break
439+
else:
440+
continue
441+
break
442442

443443
update_time = time.time() - update_time
444444

0 commit comments

Comments
 (0)