Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fb74645
Initial commit and skeleton for NonlinearMinimizer
Jan 30, 2015
a7ee059
Merge branch 'qp' of https://github.com/debasish83/breeze into nlqp
Jan 31, 2015
679bb5f
Skeleton for approximate eigen value calculation
Feb 2, 2015
3d80b31
Copyright message for NonlinearMinimizer
Feb 2, 2015
3781e37
merge with qp branch; NOTICE file updated
Feb 3, 2015
536886d
Initial checkin for PowerMethod and PowerMethodTest;Eigen value extra…
Feb 3, 2015
f98bd80
Compilation fixes to LBFGS eigenMin and eigenMax
Feb 4, 2015
ae795b6
Power Method merged; NonlinearMinimizer now supports preserving histo…
Feb 11, 2015
51b4224
Generating PQN.CompactHessian from BFGS.ApproximateInverseHessian not…
Feb 11, 2015
ee697bf
Linear Regression formulation added for comparisons
Feb 11, 2015
ce8638f
Fixed LBFGS.maxEigen using power law on CompactHessian
Feb 12, 2015
bbc3edd
Merge branch 'qp' of https://github.com/debasish83/breeze into nlqp
Feb 17, 2015
f85ff86
Merge branch 'qp' of https://github.com/debasish83/breeze into nlqp
Feb 22, 2015
e3a61a9
Added a proximal interface to ProjectQuasiNewton solver; Added projec…
Feb 23, 2015
928de32
probability simplex benchmark
Feb 24, 2015
91f2e17
After experimentation NonlinearMinimizer now users PQN/OWLQN and supp…
Feb 28, 2015
33d28ff
Add testcases for Least square variants
Mar 1, 2015
6cba897
merge with upstream
Mar 1, 2015
9bef354
I dunno.
dlwh Mar 1, 2015
18c7789
PQN fixes from David's fix_pqn branch; added strong wolfe line search…
Mar 2, 2015
43794c0
Unused import from FirstOrderMinimizer; PQN migrated to Strong Wolfe …
Mar 5, 2015
e2c1db8
Used BacktrackingLineSearch in SPG and PQN; Updated NonlinearMinimize…
Mar 5, 2015
defaff5
NonlinearMinimizer println changed to nl from pqn
Mar 5, 2015
610027f
Updated with cforRange in proximal operations
Mar 7, 2015
8c6a6c8
BacktrackingLineSearch takes an initfval;OWLQN, PQN and SPG updated t…
Mar 7, 2015
b4d86e8
Merge branch 'master' of https://github.com/scalanlp/breeze into nlqp
Mar 7, 2015
3a6fc97
infiniteIteration API in FirstOrderMinimizer takes initialState;PQN b…
Mar 11, 2015
8533ada
migrate LBFGS Eigen calculation to https://github.com/debasish83/bree…
Mar 11, 2015
a0bbd33
cleaned up minEigen call from QuadraticMinimizer
Mar 11, 2015
40a45a8
NonlinearMinimizer inner iterations through BFGS cleaned
Mar 12, 2015
7308c7a
Updated contributions in README.md
Mar 12, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Compilation fixes to LBFGS eigenMin and eigenMax
  • Loading branch information
Debasish Das committed Feb 4, 2015
commit f98bd80e54fc355a356a356b55f24120aeeb0d6c
16 changes: 6 additions & 10 deletions math/src/main/scala/breeze/optimize/LBFGS.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import breeze.linalg._
import breeze.linalg.operators.OpMulMatrix
import breeze.math.MutableInnerProductModule
import breeze.optimize.linear.PowerMethod
import breeze.optimize.proximal.QuadraticMinimizer
import breeze.stats.distributions.Rand
import breeze.util.SerializableLogging

/**
Expand Down Expand Up @@ -88,13 +86,12 @@ class LBFGS[T](maxIter: Int = -1, m: Int=10, tolerance: Double=1E-9)
* specified through DiffFunction through power iteration on ApproximateInverseHessian,
* get the largest eigenvalue e and return 1/e
*
* @param n the size of the problem, can be infered from memStep/memGradDelta
* @param init initial guess for eigen vector
* @param state the current state of the optimization
* @return minimium eigen eigen value
*/
protected def minEigen(n: Int, state: State) : Double = {
val pm = new PowerMethod[DenseVector[Double], LBFGS.ApproximateInverseHessian[T]]
val init = DenseVector.rand[Double](n, Rand.gaussian(0, 1))
protected def minEigen(init: T, state: State) : Double = {
val pm = new PowerMethod[T, LBFGS.ApproximateInverseHessian[T]]()(space,LBFGS.multiplyInverseHessian)
val eigenMax = pm.eigen(init, state.history)
1.0/eigenMax
}
Expand All @@ -104,17 +101,16 @@ class LBFGS[T](maxIter: Int = -1, m: Int=10, tolerance: Double=1E-9)
* through DiffFunction by doing a inverse power iteration using the CompactHessian representation
* generated from ApproximateInverseHessian, get the largest eigenvalue e
*
* @param n the size of the problem, can be infered from memStep/memGradDelta
* @param init initial guess for the eigen vector
* @param state the current state of the optimization
* @return maximum eigen value
*/
protected def maxEigen(n: Int, state: State, init: DenseVector[Double]) : Double = {
protected def maxEigen(init:T, state: State) : Double = {
val compactHessian = new CompactHessian(state.history.m)
val memStep = state.history.memStep.asInstanceOf[Seq[DenseVector[Double]]]
val memGradDelta = state.history.memGradDelta.asInstanceOf[Seq[DenseVector[Double]]]
(0 to state.history.historyLength).map{i => compactHessian.updated(memStep(i), memGradDelta(i))}
val init = DenseVector.rand[Double](n, Rand.gaussian(0, 1))
val pm = new PowerMethod[DenseVector[Double], CompactHessian]
val pm = new PowerMethod[T, CompactHessian]()(space, ProjectedQuasiNewton.multiplyCompactHessian)
pm.eigen(init, compactHessian)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package breeze.optimize

import breeze.linalg._
import breeze.collection.mutable.RingBuffer
import breeze.linalg.operators.OpMulMatrix
import breeze.math.{MutableInnerProductModule}
import breeze.util.SerializableLogging

Expand Down Expand Up @@ -184,5 +185,11 @@ object ProjectedQuasiNewton {
(f, g)
}
}

implicit def multiplyCompactHessian[T](implicit vspace: MutableInnerProductModule[T, Double]): OpMulMatrix.Impl2[CompactHessian, T, T] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this definitely has to go.

new OpMulMatrix.Impl2[CompactHessian, T, T] {
def apply(a: CompactHessian, b: T): T = a * b
}
}
}

10 changes: 7 additions & 3 deletions math/src/main/scala/breeze/optimize/linear/PowerMethod.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package breeze.optimize.linear

import breeze.linalg.operators.OpMulMatrix
import breeze.math.MutableInnerProductVectorSpace
import breeze.math.{MutableInnerProductModule}
import breeze.numerics.abs
import breeze.util.SerializableLogging
import breeze.linalg.norm
Expand All @@ -27,7 +27,8 @@ import breeze.util.Implicits._
* Created by debasish83 on 2/3/15.
*/
class PowerMethod[T, M](maxIterations: Int = 10,tolerance: Double = 1E-5)
(implicit space: MutableInnerProductVectorSpace[T, Double], mult: OpMulMatrix.Impl2[M, T, T]) extends SerializableLogging {
(implicit space: MutableInnerProductModule[T, Double],
mult: OpMulMatrix.Impl2[M, T, T]) extends SerializableLogging {

import space._

Expand Down Expand Up @@ -57,7 +58,10 @@ class PowerMethod[T, M](maxIterations: Int = 10,tolerance: Double = 1E-5)

val val_dif = abs(lambda - eigenValue)
if (val_dif <= tolerance || iter > maxIterations) State(lambda, ay, iter + 1, true)
else State(lambda, ay/lambda, iter + 1, false)
else {
ay *= 1.0/lambda
State(lambda, ay, iter + 1, false)
}
}.takeUpToWhere(_.converged)

def iterateAndReturnState(y: T, A: M): State = {
Expand Down