Comments (3)
For non-square, complex valued matrix, yes, but it does not support pivoting yet.
For pivoted qr
, the computational graph looks like
A -> * P' -> qr -> Q, R
Notice P
matrix is just a permutation matrix, it does not contain anay gradient information. So the backward rule would be simplely dQ, dR -> back(qr) -> * P -> dA
.
But it would be nice to have an optional parameter. Thanks for your issue!
from backwardslinalg.jl.
e.g. define the adjoint like this (will be merged soon)
using BackwardsLinalg: qr_back, copyltu!, gradient_check
using Zygote
using Zygote: @adjoint
@adjoint function qr(A::AbstractMatrix, pivot::Val{true})
res = qr(A, pivot)
Q, R, P = Matrix(res.Q), res.R, res.P
@show P
(Q, R, P), dy -> (qr_back(Q*R, Q, R, dy[1], dy[2])*P',nothing)
end
using Random, Test
@testset "qr Q complex pivot" begin
T = Float64
Random.seed!(3)
for (M, N) in [(20, 60), (40, 40), (60, 20)]
A = randn(T, M, N)
op = randn(M, M)
op += op'
op2 = randn(N, N)
op2 += op2'
function tfunc(x)
Q, R, P = qr(x, Val(true))
v = Q[:,1]
v2 = R[2,:]
@show size(v), size(v2), size(op), size(op2)
(v'*op*v + v2'*op2*v2)[] |> real
end
@show tfunc(A)
@test gradient_check(tfunc, A)
end
a = [1+1im 2+1im; 3-1im 4+2im]
@test copyltu!(a) ≈ [1 3+1im; 3-1im 4]
end
``
from backwardslinalg.jl.
I have pushed to master directly (since no one is reviewing me)
see this commit for reference.
Note: all these functions are pirating LinearAlgebra
, I will try to avoid this in 0.2.
from backwardslinalg.jl.
Related Issues (12)
- References
- Working with QR gradients HOT 2
- Consider string literal interface HOT 1
- lapack exception (2) backward qr diff HOT 4
- Merge into ChainRules? HOT 2
- Batched SVD
- GPU support HOT 2
- return `SVD` and `QR` types to stay compatible with julialang
- register the package HOT 15
- For registration HOT 1
- register HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backwardslinalg.jl.