We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
SqMahalanobis
1 parent ec19a94 commit 9a2f7bbCopy full SHA for 9a2f7bb
Project.toml
@@ -1,6 +1,6 @@
1
name = "KernelFunctions"
2
uuid = "ec8451be-7e33-11e9-00cf-bbf324bd1392"
3
-version = "0.10.59"
+version = "0.10.60"
4
5
[deps]
6
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
src/chainrules.jl
@@ -121,28 +121,6 @@ function ChainRulesCore.rrule(s::Sinus, x::AbstractVector, y::AbstractVector)
121
return val, evaluate_pullback
122
end
123
124
-## Reverse Rules SqMahalanobis
125
-
126
-function ChainRulesCore.rrule(
127
- dist::Distances.SqMahalanobis, a::AbstractVector, b::AbstractVector
128
-)
129
- d = dist(a, b)
130
- function SqMahalanobis_pullback(Δ::Real)
131
- a_b = a - b
132
- ∂qmat = InplaceableThunk(
133
- X̄ -> mul!(X̄, a_b, a_b', true, Δ), @thunk((a_b * a_b') * Δ)
134
- )
135
- ∂a = InplaceableThunk(
136
- X̄ -> mul!(X̄, dist.qmat, a_b, true, 2 * Δ), @thunk((2 * Δ) * dist.qmat * a_b)
137
138
- ∂b = InplaceableThunk(
139
- X̄ -> mul!(X̄, dist.qmat, a_b, true, -2 * Δ), @thunk((-2 * Δ) * dist.qmat * a_b)
140
141
- return Tangent{typeof(dist)}(; qmat=∂qmat), ∂a, ∂b
142
- end
143
- return d, SqMahalanobis_pullback
144
-end
145
146
## Reverse Rules for matrix wrappers
147
148
function ChainRulesCore.rrule(::Type{<:ColVecs}, X::AbstractMatrix)
test/chainrules.jl
@@ -3,8 +3,6 @@
x = rand(rng, 5)
y = rand(rng, 5)
r = rand(rng, 5)
- Q = Matrix(Cholesky(rand(rng, 5, 5), 'U', 0))
7
- @assert isposdef(Q)
8
9
compare_gradient(:Zygote, [x, y]) do xy
10
Euclidean()(xy[1], xy[2])
@@ -21,11 +19,4 @@
21
19
22
20
KernelFunctions.Sinus(r)(xy[1], xy[2])
23
24
- if VERSION < v"1.6"
25
- @test_broken "Chain rule of SqMahalanobis is broken in Julia pre-1.6"
26
- else
27
- compare_gradient(:Zygote, [Q, x, y]) do Qxy
28
- SqMahalanobis(Qxy[1])(Qxy[2], Qxy[3])
29
30
31
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments