madeleineudell / LowRankModels.jl

LowRankModels.jl is a julia package for modeling and fitting generalized low rank models.
Other
190 stars 65 forks source link

init_svd! fails for rank-one model #28

Closed ahwillia closed 9 years ago

ahwillia commented 9 years ago

Minor issue I happened to come across. I might try to chase this down this afternoon.

using LowRankModels

m = 100
n = 100
k = 1 # changing k to be 2 or 3 fixes this

A = randn(m,k)*randn(k,n)
loss = quadratic()
r = zeroreg()
glrm = GLRM(A,loss,r,r,k)
init_svd!(glrm)

Produces an error:

ERROR: DimensionMismatch("*")
 in gemm_wrapper! at linalg/matmul.jl:270
 in A_mul_Bt at linalg/matmul.jl:141
 in A_mul_Bc at linalg/matmul.jl:172
 in init_svd! at /Users/alex/.julia/v0.3/LowRankModels/src/initialize.jl:74

This seems to only be an issue for rank-one models (changing k to be 2 or 3 fixes it).

ahwillia commented 9 years ago

So this is essentially occurring because k is decremented and becomes zero on this line: https://github.com/madeleineudell/LowRankModels.jl/blob/master/src/initialize.jl#L53

Seems like a subjective call on how to fix this. Maybe leave the code as is, but throw an error when k=0 telling the user to set offset=false to initialize a rank-one model with demeaned data.

madeleineudell commented 9 years ago

Yes, I think a warning would be the right thing here. Thanks for catching that. On Aug 1, 2015 11:19 PM, "Alex Williams" notifications@github.com wrote:

So this is essentially occurring because k is decremented and becomes zero on this line: https://github.com/madeleineudell/LowRankModels.jl/blob/master/src/initialize.jl#L53

Seems like a subjective call on how to fix this. Maybe leave the code as is, but throw an error when k=0 telling the user to set offset=false to initialize a rank-one model with demeaned data.

— Reply to this email directly or view it on GitHub https://github.com/madeleineudell/LowRankModels.jl/issues/28#issuecomment-126994026 .