-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add grad for det, logdet and inv #46
Conversation
f9e3710
to
0d7bf3f
Compare
0d7bf3f
to
63eb6ff
Compare
merge? |
6a42a5b
to
6ec63b8
Compare
6ec63b8
to
81dc8cf
Compare
@CarloLucibello thanks for your efforts. I've just reviewed your implementations. Here are some issues I've discovered, do you have any solution or suggestion to solve these problems:
julia> gradcheck(trace, rand(4,4)) # I am aware of that your test works
julia> my_trace(x) = sum(trace(x)); my_trace(rand(4,4)) # works fine
julia> gradcheck(my_trace, rand(1,1)) # not working 2.logdet Implementation julia> t1
4×4 Array{Float64,2}:
0.81897 0.972307 0.59813 0.408066
0.736922 0.451799 0.946951 0.141639
0.127154 0.466463 0.271822 0.872671
0.864788 0.0628381 0.205276 0.918354
julia> logdet(t1)
ERROR: DomainError:
log will only return a complex result if called with a complex argument. Try log(complex(x)).
Stacktrace:
[1] nan_dom_err at ./math.jl:300 [inlined]
[2] log at ./math.jl:419 [inlined]
[3] logdet(::Array{Float64,2}) at ./linalg/generic.jl:1261
julia> t2
4×4 Array{Float64,2}:
0.177807 0.518924 0.721952 0.305002
0.244914 0.629782 0.704174 0.394654
0.686861 0.486215 0.583889 0.902661
0.756204 0.965346 0.766321 0.209436
julia> logdet(t2)
-3.283823415533983
julia> logdet(complex(t1))
-0.7562876304616563 - 3.141592653589793im
# Pls try the following line for a few times, in case want to test by yourself :
julia> [ gradcheck(logdet, eye(3) + rand(3,3)) for i in 1:1000 ];
|
Hi, thanks for review.
This seems to be bug #46, unrelated to this PR
This is ok, that error is supposed to manifest when the determinant is negative |
I modified the logdet test to have it more unlikely to fail |
@CarloLucibello I saw your change, other gradient checks are OK. |
and also trace, diag, diagm, logabsdet, triu, tril
x-ref #45