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

missing method AD'ing through a QR decomposition #286

Open
tpapp opened this issue Dec 15, 2017 · 1 comment
Open

missing method AD'ing through a QR decomposition #286

tpapp opened this issue Dec 15, 2017 · 1 comment

Comments

@tpapp
Copy link
Contributor

tpapp commented Dec 15, 2017

Could not reduce this to a MWE yet, but I get this error message when using ForwardDiff.jacobian on a problem that uses the QR decomposition for least squares.

ERROR: MethodError: no method matching A_ldiv_B!(::Base.LinAlg.QRCompactWY{ForwardDiff.Dual{ForwardDiff.Tag{IndirectLikelihood.##3#4{IndirectLikelihood.IndirectLikelihoodProblem{SinglesModel{Float64},AuxModel,SinglesData{Float64,Float64}}},Float64},Float64,4},Array{ForwardDiff.Dual{ForwardDiff.Tag{IndirectLikelihood.##3#4{IndirectLikelihood.IndirectLikelihoodProblem{SinglesModel{Float64},AuxModel,SinglesData{Float64,Float64}}},Float64},Float64,4},2}}, ::Array{ForwardDiff.Dual{ForwardDiff.Tag{IndirectLikelihood.##3#4{IndirectLikelihood.IndirectLikelihoodProblem{SinglesModel{Float64},AuxModel,SinglesData{Float64,Float64}}},Float64},Float64,4},2})
Closest candidates are:
  A_ldiv_B!(::Base.LinAlg.QR{T,S} where S<:(AbstractArray{T,2} where T), ::Union{Base.ReshapedArray{T,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T}, DenseArray{T,2}, SubArray{T,2,A,I,L} where L} where I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex, Int64, Range{Int64}},N} where N} where A<:Union{Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T} where N where T, DenseArray}) where T at linalg/qr.jl:730
  A_ldiv_B!(::Base.LinAlg.QRPivoted, ::Union{Base.ReshapedArray{T,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T}, DenseArray{T,2}, SubArray{T,2,A,I,L} where L} where I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex, Int64, Range{Int64}},N} where N} where A<:Union{Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T} where N where T, DenseArray} where T) at linalg/qr.jl:782
  A_ldiv_B!(::Base.LinAlg.LQ{T,S} where S<:(AbstractArray{T,2} where T), ::Union{Union{Base.ReshapedArray{T,1,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T}, DenseArray{T,1}, SubArray{T,1,A,I,L} where L} where I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex, Int64, Range{Int64}},N} where N} where A<:Union{Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T} where N where T, DenseArray}, Union{Base.ReshapedArray{T,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T}, DenseArray{T,2}, SubArray{T,2,A,I,L} where L} where I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex, Int64, Range{Int64}},N} where N} where A<:Union{Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T} where N where T, DenseArray}}) where T at linalg/lq.jl:234
  ...
Stacktrace:
 [1] \(::Base.LinAlg.QRCompactWY{Float64,Array{Float64,2}}, ::Array{ForwardDiff.Dual{ForwardDiff.Tag{IndirectLikelihood.##3#4{IndirectLikelihood.IndirectLikelihoodProblem{SinglesModel{Float64},AuxModel,SinglesData{Float64,Float64}}},Float64},Float64,4},2}) at ./linalg/qr.jl:819

Importantly, in the X \ Y the Y is a matrix, not a vector (multiple independent variables).

Using Julia v0.6.1, tried both ForwardDiff master and 0.7.0. A workaround would also help.

@tpapp
Copy link
Contributor Author

tpapp commented Dec 15, 2017

I realized that I can just use qrfact(X, Val{true}) (ie pivoting) and that works. So perhaps this issue should be revisited after Julia v0.7 comes out, since JuliaLang/julia#24969 changed a lot of the internals.

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

1 participant