Update optim.py (#1366)

This commit is contained in:
zr_jin 2023-11-03 12:06:29 +08:00 committed by GitHub
parent c3bbb32f9e
commit 231bbcd2b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -466,6 +466,8 @@ class ScaledAdam(BatchedOptimizer):
quartiles.append(sorted_norms[index].item())
median = quartiles[2]
if median - median != 0:
raise RuntimeError("Too many grads were not finite")
threshold = clipping_scale * median
if step in irregular_estimate_steps:
# use larger thresholds on first few steps of estimating threshold,