Skip to content
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

Merged
merged 5 commits into from
Mar 18, 2018

Conversation

CarloLucibello
Copy link
Collaborator

@CarloLucibello CarloLucibello commented Feb 17, 2018

and also trace, diag, diagm, logabsdet, triu, tril
x-ref #45

@CarloLucibello
Copy link
Collaborator Author

merge?

@kirnap
Copy link

kirnap commented Feb 26, 2018

@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:

  1. trace Implementation
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 ];

@denizyuret

  1. For all other implementations we need KnetArray Implementations.
  2. In the logdet implementation issue we may face the following error:
    julia ERROR: MethodError: no method matching complex(::AutoGrad.Rec{Array{Float64,2}})

@CarloLucibello
Copy link
Collaborator Author

CarloLucibello commented Feb 26, 2018

Hi, thanks for review.
Both problems should be fine:

  1. trace Implementation

This seems to be bug #46, unrelated to this PR

2.logdet Implementation

This is ok, that error is supposed to manifest when the determinant is negative

@CarloLucibello
Copy link
Collaborator Author

I modified the logdet test to have it more unlikely to fail

@kirnap
Copy link

kirnap commented Feb 26, 2018

@CarloLucibello I saw your change, other gradient checks are OK.

@denizyuret denizyuret merged commit 9af9dc3 into denizyuret:master Mar 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants