Giter VIP home page Giter VIP logo

mohamed82008 / differentiablefactorizations.jl Goto Github PK

View Code? Open in Web Editor NEW
30.0 1.0 1.0 20 KB

Differentiable matrix factorizations using ImplicitDifferentiation.jl.

License: MIT License

Julia 100.00%
automatic-differentiation cholesky-decomposition eigendecomposition forward-mode-autodiff generalized-eigenvalue implicit-differentiation lu-decomposition matrix-decompositions matrix-factorization qr-decomposition

differentiablefactorizations.jl's People

Contributors

github-actions[bot] avatar mohamed82008 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

phrygiangates

differentiablefactorizations.jl's Issues

Test sparse and GPU matrices

The main advantage of the approach taken here is that it's friendly to sparse matrices and GPU arrays. We need some tests for those.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

add ordschur!

Hi,

now that schur is implemented it would be helpful to implement ordschur(!) as well

My starting point would be this.

add Schur(A,B) decomposition

Hi,

I tried to implement schur(A,B) the way you did for the eigen decomposition but the solver doesn't find a solution.

My guess is that numerical stability in the decomposition might be an issue here. What's your experience with the other decompositions? Any hints?

Here is some code to show what I mean:

using LinearAlgebra, SparseArrays, ChainRulesCore, ImplicitDifferentiation, ComponentArrays, Zygote, Krylov, FiniteDifferences

D = [
 0.0  -1.0         -0.213967   0.0        0.0       0.0
 0.0   0.0          0.0        0.0        0.0       0.0
 0.0   0.0         -0.77138    0.0        0.335701  0.404972
 0.0   0.0          0.636374   0.0        0.40692   0.490887
 0.0   0.00173608   0.0       -0.0194976  0.683867  0.0
 1.0   0.0          0.0        0.0        0.0       0.0
]

E =[
 -0.0  -1.001  -0.0       -1.42321   1.0       -0.0
 -0.9  -0.0    -0.0        1.0      -0.0       -0.0
 -0.0  -0.0    -0.694242  -0.0       0.335701   0.607458
 -0.0  -0.0     0.572737  -0.0       0.40692    0.73633
 -0.0  -0.0    -0.0       -0.0       0.683867  -0.0
  0.0   0.0     0.0        1.0       0.0        0.0
]

comp_vec(A, B) = ComponentVector((; A, B))

function ChainRulesCore.rrule(::typeof(comp_vec), A, B)
    out = comp_vec(A, B)
    T = typeof(out)
    return out, Δ -> begin
        _Δ = convert(T, Δ)
        (NoTangent(), _Δ.A, _Δ.B) 
    end
end
  

function schur_conditions(ab, F)
    (; left, right, S, T) = F
    (; A, B) = ab
    return vcat(
        vec(A - left * S * right'),
        vec(B - left * T * right')
    )
end

function schur_forward(ab)
    (; A, B) = ab
    
    SCH = schur(A, B)

    left = SCH.left
    right = SCH.right
    S = SCH.S
    T = SCH.T

    # left = sparse(SCH.left)
    # right = sparse(SCH.right)
    # S = sparse(SCH.S)
    # T = sparse(SCH.T)

    # droptol!(left,eps(Float32))
    # droptol!(right,eps(Float32))
    # droptol!(S,eps(Float32))
    # droptol!(T,eps(Float32))

    return ComponentVector(; left, right, S, T)
end
  
_diff_schur = ImplicitFunction(schur_forward, schur_conditions, Krylov.bicgstab)

#function diff_schur(AB)
#    (;A,B) = AB
#    (; left, right, S, T) = _diff_schur(comp_vec(A, B))
#    return ComponentVector(; left, right , S, T)
#end
  
AB = ComponentVector(; A = D, B = E)

#f1(AB) = begin
#    A = AB.A
#    B = AB.B
#    diff_schur(A, B)
#end

zjac1 = Zygote.jacobian(_diff_schur, AB)[1]
fjac1 = FiniteDifferences.jacobian(central_fdm(5, 1), _diff_schur, AB)[1]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.