Skip to content

Commit f2b0cc6

Browse files
1 parent 7cfed2b commit f2b0cc6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/OptimizationZygoteExt.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true}, x,
1414
grad = function (res, θ, args...)
1515
val = Zygote.gradient(x -> _f(x, args...), θ)[1]
1616
if val === nothing
17-
res .= zero(typeof(θ))
17+
res .= zero(eltype(θ))
1818
else
1919
res .= val
2020
end
@@ -92,7 +92,7 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{true},
9292
grad = function (res, θ, args...)
9393
val = Zygote.gradient(x -> _f(x, args...), θ)[1]
9494
if val === nothing
95-
res .= zero(typeof(θ))
95+
res .= zero(eltype(θ))
9696
else
9797
res .= val
9898
end
@@ -170,7 +170,7 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false}, x
170170
grad = function (θ, args...)
171171
val = Zygote.gradient(x -> _f(x, args...), θ)[1]
172172
if val === nothing
173-
return zero(typeof(θ))
173+
return zero(eltype(θ))
174174
else
175175
return val
176176
end
@@ -253,7 +253,7 @@ function OptimizationBase.instantiate_function(f::OptimizationFunction{false},
253253
grad = function (θ, args...)
254254
val = Zygote.gradient(x -> _f(x, args...), θ)[1]
255255
if val === nothing
256-
return zero(typeof(θ))
256+
return zero(eltype(θ))
257257
else
258258
return val
259259
end

0 commit comments

Comments
 (0)