Skip to content

Commit 4871131

Browse files
committed
Not change NaN if reset_if_nan is False
1 parent a13b4de commit 4871131

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

ferminet/train.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,11 @@ def learning_rate_schedule(t_: jnp.ndarray) -> jnp.ndarray:
979979
loss = loss[0]
980980
# per batch variance isn't informative. Use weighted mean and variance
981981
# instead.
982-
if not jnp.isnan(loss):
982+
if cfg.optim.reset_if_nan and jnp.isnan(loss):
983+
fallback_loss = weighted_stats.mean if weighted_stats is not None else 0.0
984+
weighted_stats = statistics.exponentialy_weighted_stats(
985+
alpha=0.1, observation=fallback_loss, previous_stats=weighted_stats)
986+
else:
983987
weighted_stats = statistics.exponentialy_weighted_stats(
984988
alpha=0.1, observation=loss, previous_stats=weighted_stats)
985989
pmove = pmove[0]

0 commit comments

Comments
 (0)