mohamed82008 / differentiablefactorizations.jl Goto Github PK
View Code? Open in Web Editor NEWDifferentiable matrix factorizations using ImplicitDifferentiation.jl.
License: MIT License
Differentiable matrix factorizations using ImplicitDifferentiation.jl.
License: MIT License
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.
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!
Hi,
now that schur is implemented it would be helpful to implement ordschur(!) as well
My starting point would be this.
@JuliaRegistrator register
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]
Thank you @mohamed82008 for this package. Can it solve JuliaDiff/ForwardDiff.jl#602?
I wonder if we can easily use the factorizations implemented here with Turing.jl models.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.