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

Positive Semidefinite FDM #52

Open
Roger-luo opened this issue Nov 10, 2019 · 2 comments
Open

Positive Semidefinite FDM #52

Roger-luo opened this issue Nov 10, 2019 · 2 comments

Comments

@Roger-luo
Copy link
Contributor

Roger-luo commented Nov 10, 2019

central_fdm will cause problem when one wants the input always being positive semidefinite, e.g the real value logdet function. It cause the gradcheck of logdet in Zygote fails occasionally, any idea how to preserve this property while doing FDM?

Update: I workaround it by doing

gradcheck(x->logdet(x * x'), rand(4, 4))
@willtebbutt
Copy link
Member

Ah, yes, this is generally problematic. I always do something similar to what you've done (I'll usually add the identity to x * x' to ensure it's reasonably well conditioned though), but it's not a particularly satisfying solution.

@wesselb
Copy link
Member

wesselb commented Dec 17, 2020

Perhaps a bit of an old issue, but just wanted to remark that there is also the solution of using forward_fdm instead of central_fdm:

julia> x = randn(2, 2); x = x'x;

julia> v = randn(2, 2); v = v'v;

julia> forward_fdm(5, 1)(ε -> logdet(x + ε .* v), 0)
38.547460846816136

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

No branches or pull requests

3 participants