Skip to content

Commit 1aa8780

Browse files
Use broadcasting for NaN/Inf check
Use any(.!(isfinite.(G))) to properly handle arrays with broadcasting
1 parent 8fd8cef commit 1aa8780

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/OptimizationOptimisers/src/OptimizationOptimisers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function SciMLBase.__solve(cache::OptimizationCache{O}) where {O <: AbstractRule
130130
end
131131
end
132132
# Skip update if gradient contains NaN or Inf values
133-
has_nan_or_inf = any(isnan, G) || any(isinf, G)
133+
has_nan_or_inf = any(.!(isfinite.(G)))
134134
if !has_nan_or_inf
135135
state, θ = Optimisers.update(state, θ, G)
136136
else

0 commit comments

Comments
 (0)