Skip to content

Positive Semidefinite FDM #52

Open

Description

@Roger-luo

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))

Activity

  1. willtebbutt commented on Nov 10, 2019

    @willtebbutt
    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.

  2. wesselb commented on Dec 17, 2020

    @wesselb
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions