@@ -7,29 +7,32 @@ dims = [10,5]
7
7
A = rand (dims... )
8
8
B = rand (dims... )
9
9
K = [zeros (dims[1 ],dims[1 ]),zeros (dims[2 ],dims[2 ])]
10
- kernels = [SquaredExponentialKernel]
10
+ kernels = [SquaredExponentialKernel,MaternKernel ]
11
11
l = 2.0
12
12
vl = l* ones (dims[1 ])
13
13
testfunction (k,A,B) = sum (kernelmatrix (k,A,B))
14
14
testfunction (k,A) = sum (kernelmatrix (k,A))
15
15
16
- testfunction (SquaredExponentialKernel (vl),A)
17
16
# #Eventually store real results in file
18
17
@testset " Zygote Automatic Differentiation test" begin
19
18
@testset " ARD" begin
20
19
for k in kernels
21
- @test all (isapprox .(Zygote. gradient (x-> testfunction (k (x),A,B),vl)[1 ], ForwardDiff. gradient (x-> testfunction (k (x),A,B),vl)))
22
- @test all (isapprox .(Zygote. gradient (x-> testfunction (k (vl),x,B),A)[1 ],ForwardDiff. gradient (x-> testfunction (k (vl),x,B),A)))
23
- @test all (isapprox .(Zygote. gradient (x-> testfunction (k (x),A),vl)[1 ],ForwardDiff. gradient (x-> testfunction (k (x),A),vl)))
24
- @test all (isapprox .(Zygote. gradient (x-> testfunction (k (vl),x),A)[1 ],ForwardDiff. gradient (x-> testfunction (k (vl),x),A)))
20
+ @testset " $k " begin
21
+ @test all (isapprox .(Zygote. gradient (x-> testfunction (k (x),A,B),vl)[1 ], ForwardDiff. gradient (x-> testfunction (k (x),A,B),vl)))
22
+ @test all (isapprox .(Zygote. gradient (x-> testfunction (k (vl),x,B),A)[1 ],ForwardDiff. gradient (x-> testfunction (k (vl),x,B),A)))
23
+ @test all (isapprox .(Zygote. gradient (x-> testfunction (k (x),A),vl)[1 ],ForwardDiff. gradient (x-> testfunction (k (x),A),vl)))
24
+ @test all (isapprox .(Zygote. gradient (x-> testfunction (k (vl),x),A)[1 ],ForwardDiff. gradient (x-> testfunction (k (vl),x),A)))
25
+ end
25
26
end
26
27
end
27
28
@testset " ISO" begin
28
29
for k in kernels
29
- @test all (isapprox .(Zygote. gradient (x-> testfunction (k (x),A,B),l)[1 ],ForwardDiff. gradient (x-> testfunction (k (x[1 ]),A,B),[l])[1 ]))
30
- @test all (isapprox .(Zygote. gradient (x-> testfunction (k (l),x,B),A)[1 ],ForwardDiff. gradient (x-> testfunction (k (l),x,B),A)))
31
- @test all (isapprox .(Zygote. gradient (x-> testfunction (k (x),A),l)[1 ],ForwardDiff. gradient (x-> testfunction (k (x[1 ]),A),[l])))
32
- @test all (isapprox .(Zygote. gradient (x-> testfunction (k (l),x),A)[1 ],ForwardDiff. gradient (x-> testfunction (k (l[1 ]),x),A)))
30
+ @testset " $k " begin
31
+ @test all (isapprox .(Zygote. gradient (x-> testfunction (k (x),A,B),l)[1 ],ForwardDiff. gradient (x-> testfunction (k (x[1 ]),A,B),[l])[1 ]))
32
+ @test all (isapprox .(Zygote. gradient (x-> testfunction (k (l),x,B),A)[1 ],ForwardDiff. gradient (x-> testfunction (k (l),x,B),A)))
33
+ @test all (isapprox .(Zygote. gradient (x-> testfunction (k (x),A),l)[1 ],ForwardDiff. gradient (x-> testfunction (k (x[1 ]),A),[l])))
34
+ @test all (isapprox .(Zygote. gradient (x-> testfunction (k (l),x),A)[1 ],ForwardDiff. gradient (x-> testfunction (k (l[1 ]),x),A)))
35
+ end
33
36
end
34
37
end
35
38
end
0 commit comments