Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
denizyuret committed Aug 7, 2018
1 parent 99309ce commit 7cd6e40
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 20 deletions.
16 changes: 8 additions & 8 deletions src/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import Base: acos, acosd, acosh, acot, acotd, acoth, acsc, acscd, acsch, asec, a
@primitive acot(x),dy (dy.*(-1 ./ (1 .+ abs2.(x))))
@primitive acotd(x),dy (dy.*(-(180 / pi) ./ (1 .+ abs2.(x))))
@primitive acoth(x),dy (dy.*(1 ./ (1 .- abs2.(x))))
@primitive acsc(x),dy (dy.*(-1 ./ sqrt.(((x .* x) .* (x .- 1)) .* (x .+ 1))))
@primitive acscd(x),dy (dy.*(-(180 / pi) ./ sqrt.(((x .* x) .* (x .- 1)) .* (x .+ 1))))
@primitive acsch(x),dy (dy.*(-1 ./ sqrt.(x .^ 4. + x .^ 2.)))
@primitive asec(x),dy (dy.*(1 ./ sqrt.(x .^ 4. - x .^ 2.)))
@primitive asecd(x),dy (dy.*((180 / pi) ./ sqrt.(x .^ 4. - x .^ 2.)))
@primitive asech(x),dy (dy.*(-1 ./ sqrt.(x .^ 2. - x .^ 4.)))
@primitive acsc(x),dy (dy.*(-1 ./ sqrt.((abs2.(x) .* (x .- 1)) .* (x .+ 1))))
@primitive acscd(x),dy (dy.*(-(180 / pi) ./ sqrt.((abs2.(x) .* (x .- 1)) .* (x .+ 1))))
@primitive acsch(x),dy (dy.*(-1 ./ sqrt.(abs2.(abs2.(x)) + abs2.(x))))
@primitive asec(x),dy (dy.*(1 ./ sqrt.(abs2.(abs2.(x)) - abs2.(x))))
@primitive asecd(x),dy (dy.*((180 / pi) ./ sqrt.(abs2.(abs2.(x)) - abs2.(x))))
@primitive asech(x),dy (dy.*(-1 ./ sqrt.(abs2.(x) - abs2.(abs2.(x)))))
@primitive asin(x),dy (dy.*(1 ./ sqrt.(1 .- abs2.(x))))
@primitive asind(x),dy (dy.*((180 / pi) ./ sqrt.(1 .- abs2.(x))))
@primitive asinh(x),dy (dy.*(1 ./ sqrt.(1 .+ abs2.(x))))
Expand Down Expand Up @@ -45,7 +45,7 @@ import Base: acos, acosd, acosh, acot, acotd, acoth, acsc, acscd, acsch, asec, a
@zerograd exponent(x)
# frexp
@primitive hypot(x1,x2),dy,y unbroadcast(x1,dy.*(x1./y)) unbroadcast(x2,dy.*(x2./y))
@primitive ldexp(x,n),dy (dy.*(2.0 .^ n))
@primitive ldexp(x,n),dy (dy.*(2 .^ n))
@primitive log(x),dy (dy.*(1 ./ x))
@primitive log(x1,x2),dy,y unbroadcast(x1,dy.*(-log.(x2)./(x1.*abs2.(log.(x1))))) unbroadcast(x2,dy.*(1 ./ (x2.*log.(x1))))
@primitive log10(x),dy (dy.*(1 ./ (log(10) .* x)))
Expand All @@ -61,7 +61,7 @@ import Base: acos, acosd, acosh, acot, acotd, acoth, acsc, acscd, acsch, asec, a
@primitive sec(x),dy,y (dy.*(y .* tan.(x)))
@primitive secd(x),dy,y (dy.*(((y .* tand.(x)) * pi) / 180))
@primitive sech(x),dy,y (dy.*(-y .* tanh.(x)))
@primitive significand(x),dy (dy.*(0.5 .^ exponent.(x)))
@primitive significand(x),dy (dy.*(2 .^ -exponent.(x)))
@primitive sin(x),dy (dy.*(cos.(x)))
@primitive sinc(x),dy (dy.*(cosc.(x)))
# sincos: TODO
Expand Down
2 changes: 1 addition & 1 deletion test/gradcheck.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using AutoGrad
using AutoGrad, Test

# TODO: merge gradcheck and check_grads.
# gradcheck iterates over the elements of the first arg.
Expand Down
3 changes: 0 additions & 3 deletions test/header.jl

This file was deleted.

2 changes: 1 addition & 1 deletion test/highorder.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("header.jl")
include("gradcheck.jl")
@testset "highorder" begin
# info("Test higher order gradients...")
g1 = grad(sin); @test g1(1)==cos(1)
Expand Down
2 changes: 1 addition & 1 deletion test/indexing.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("header.jl")
include("gradcheck.jl")

@testset "indexing" begin

Expand Down
2 changes: 1 addition & 1 deletion test/interfaces.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("header.jl")
include("gradcheck.jl")

@testset "interfaces" begin

Expand Down
3 changes: 1 addition & 2 deletions test/math.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Test, AutoGrad

include("gradcheck.jl")

mathcheck(f,t=identity)=(g(x)=f.(x); gradcheck(f,t(randn())) && gradcheck(g,t.(randn(2))))

@testset "math" begin
Expand Down
2 changes: 1 addition & 1 deletion test/neuralnet.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("header.jl")
include("gradcheck.jl")

# info("Test neural net...")
n0(w,x,y)=sum(abs2,((w[3]*max.(0,w[1]*x.+w[2]).+w[4])-y))
Expand Down
2 changes: 1 addition & 1 deletion test/primitives.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("header.jl")
include("gradcheck.jl")

@testset "primitives" begin
for t in AutoGrad.alltests()
Expand Down
2 changes: 1 addition & 1 deletion test/rosenbrock.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("header.jl")
include("gradcheck.jl")

@testset "rosenbrock" begin
# info("Test rosenbrock with map...")
Expand Down

0 comments on commit 7cd6e40

Please sign in to comment.