Skip to content

Commit

Permalink
use hypot
Browse files Browse the repository at this point in the history
  • Loading branch information
tangwei94 authored Jun 14, 2024
1 parent 65c4902 commit 6e9bec0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ext/TensorKitChainRulesCoreExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function ChainRulesCore.rrule(::typeof(norm), a::AbstractTensorMap, p::Real=2)
p == 2 || error("currently only implemented for p = 2")
n = norm(a, p)
function norm_pullback(Δn)
return NoTangent(), a * (Δn' + Δn) / (n * 2 + eps(real(eltype(a)))), NoTangent()
return NoTangent(), a * (Δn' + Δn) / 2 / hypot(n, eps(one(n))), NoTangent()
end
return n, norm_pullback
end
Expand Down

0 comments on commit 6e9bec0

Please sign in to comment.