Skip to content

Commit

Permalink
Added inner iterations to allow learning new examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihir Paradkar committed Jan 17, 2017
1 parent 4b51525 commit fe871b8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 33 deletions.
25 changes: 14 additions & 11 deletions src/fit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function LowRankModels.fit!(g::GGLRM,

tm = 0
update_ch!(ch, tm, whole_objective(g,XY))

(objx, objy) = (NaN, NaN)
#Step sizes
αx = params.stepsize
αy = params.stepsize
Expand All @@ -210,17 +210,20 @@ function LowRankModels.fit!(g::GGLRM,
if verbose println("Fitting GGLRM") end
for t in 1:params.max_iter
#X update-----------------------------------------------------------------
#_threadedupdateGradX!(g,XY,gx)
_updateGradX!(g,XY,gx)
#Take a prox step with line search
αx, objx = _proxStepX!(g, params, newX, gx, XY, newXY, αx)
At_mul_B!(XY, X, Y) #Get the new XY matrix for objective

for xit in 1:params.inner_iter_X
#_threadedupdateGradX!(g,XY,gx)
_updateGradX!(g,XY,gx)
#Take a prox step with line search
αx, objx = _proxStepX!(g, params, newX, gx, XY, newXY, αx)
At_mul_B!(XY, X, Y) #Get the new XY matrix for objective
end
#Y Update---------------------------------------------------------------
#_threadedupdateGradY!(g,XY,gy)
_updateGradY!(g,XY,gy)
αy, objy = _proxStepY!(g, params, newY, gy, XY, newXY, αy)
At_mul_B!(XY, X, Y) #Get the new XY matrix for objective
for yit in 1:params.inner_iter_Y
#_threadedupdateGradY!(g,XY,gy)
_updateGradY!(g,XY,gy)
αy, objy = _proxStepY!(g, params, newY, gy, XY, newXY, αy)
At_mul_B!(XY, X, Y) #Get the new XY matrix for objective
end
if t % 10 == 0
if verbose
println("Iteration $t, objective value: $(objy + evaluate(rx, g.X))")
Expand Down
25 changes: 14 additions & 11 deletions src/fit_multithread.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function fit_multithread!(g::GGLRM,

tm = 0
update_ch!(ch, tm, whole_objective(g,XY))

(objx, objy) = NaN, NaN
#Step sizes
αx = params.stepsize
αy = params.stepsize
Expand All @@ -174,17 +174,20 @@ function fit_multithread!(g::GGLRM,
if verbose println("Fitting GGLRM") end
for t in 1:params.max_iter
#X update-----------------------------------------------------------------
#_threadedupdateGradX!(g,XY,gx)
_threadedupdateGradX!(g,XY,gx)
#Take a prox step with line search
αx, objx = _threadedproxStepX!(g, params, newX, gx, XY, newXY, αx)
At_mul_B!(XY, X, Y) #Get the new XY matrix for objective

for xit in 1:params.inner_iter_X
#_threadedupdateGradX!(g,XY,gx)
_threadedupdateGradX!(g,XY,gx)
#Take a prox step with line search
αx, objx = _threadedproxStepX!(g, params, newX, gx, XY, newXY, αx)
At_mul_B!(XY, X, Y) #Get the new XY matrix for objective
end
#Y Update---------------------------------------------------------------
#_threadedupdateGradY!(g,XY,gy)
_threadedupdateGradY!(g,XY,gy)
αy, objy = _threadedproxStepY!(g, params, newY, gy, XY, newXY, αy)
At_mul_B!(XY, X, Y) #Get the new XY matrix for objective
for yit in 1:params.inner_iter_Y
#_threadedupdateGradY!(g,XY,gy)
_threadedupdateGradY!(g,XY,gy)
αy, objy = _threadedproxStepY!(g, params, newY, gy, XY, newXY, αy)
At_mul_B!(XY, X, Y) #Get the new XY matrix for objective
end
if t % 10 == 0
if verbose
println("Iteration $t, objective value: $(objy + evaluate(rx, g.X))")
Expand Down
25 changes: 14 additions & 11 deletions src/fit_sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function fit_sparse!(g::GGLRM,

tm = 0
update_ch!(ch, tm, sparse_whole_objective(g,XY))

(objx, objy) = NaN, NaN
#Step sizes
αx = params.stepsize
αy = params.stepsize
Expand All @@ -206,17 +206,20 @@ function fit_sparse!(g::GGLRM,
if verbose println("Fitting GGLRM") end
for t in 1:params.max_iter
#X update-----------------------------------------------------------------
#_threadedupdateGradX!(g,XY,gx)
_threadedupdateGradX!(g,XY,gx)
#Take a prox step with line search
αx, objx = _threadedproxStepX!(g, params, newX, gx, XY, newXY, αx)
reconstruct_obs!(g, XY) #Get the new XY matrix for objective

for xit in 1:params.inner_iter_X
#_threadedupdateGradX!(g,XY,gx)
_threadedupdateGradX!(g,XY,gx)
#Take a prox step with line search
αx, objx = _threadedproxStepX!(g, params, newX, gx, XY, newXY, αx)
reconstruct_obs!(g, XY) #Get the new XY matrix for objective
end
#Y Update---------------------------------------------------------------
#_threadedupdateGradY!(g,XY,gy)
_threadedupdateGradY!(g,XY,gy)
αy, objy = _threadedproxStepY!(g, params, newY, gy, XY, newXY, αy)
reconstruct_obs!(g, XY) #Get the new XY matrix for objective
for yit in 1:params.inner_iter_Y
#_threadedupdateGradY!(g,XY,gy)
_threadedupdateGradY!(g,XY,gy)
αy, objy = _threadedproxStepY!(g, params, newY, gy, XY, newXY, αy)
reconstruct_obs!(g, XY) #Get the new XY matrix for objective
end
if t % 10 == 0
if verbose
println("Iteration $t, objective value: $(objy + evaluate(rx, g.X))")
Expand Down

0 comments on commit fe871b8

Please sign in to comment.