clip_fraction calc broken for clip_fraction=None

This commit is contained in:
Dominik Moritz Roth 2024-01-23 11:46:50 +01:00
parent 54b841654b
commit c67f78159b

View File

@ -253,8 +253,12 @@ class TRPL(BetterOnPolicyAlgorithm):
# Logging
pg_losses.append(surrogate_loss.item())
clip_fraction = th.mean((th.abs(ratio - 1) > clip_range).float()).item()
if self.clip_range is not None:
clip_fraction = th.mean((th.abs(ratio - 1) > clip_range).float()).item()
else:
clip_fraction = 0
clip_fractions.append(clip_fraction)
if self.clip_range_vf is None:
# No clipping