Fix for style_check

This commit is contained in:
Yifan Yang 2023-03-23 17:27:57 +08:00 committed by GitHub
parent 8c91b9d0cd
commit df4b615993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -681,10 +681,14 @@ class ScaledAdam(BatchedOptimizer):
p_exceed = p_abs > stored_percentiles # same shape as p
# The proportion that exceeds stored_percentiles
proportion_exceed = p_exceed.sum(dim=list(range(1, p.ndim)), keepdim=True) / numel
proportion_exceed = (
p_exceed.sum(dim=list(range(1, p.ndim)), keepdim=True) / numel
)
# Update store_percentiles
update_sign = (proportion_exceed - percentile_limit).sign()
stored_percentiles.mul_(1 + update_sign * lr / p_limit_values).clamp_(min=1.0e-20)
stored_percentiles.mul_(1 + update_sign * lr / p_limit_values).clamp_(
min=1.0e-20
)
# For these parameters that exceed stored_percentile,
# flip the update sign if they would get larger absolute values