public class HebbianSolver extends Object
Constructor and Description 

HebbianSolver(double convergenceTarget)
Creates a new HebbianSolver with the default
HebbianUpdater to do the updating work, and the default
AsyncEigenVerifier to check for convergence in a (single)
background thread, with
maxPassesPerEigen set to Integer.MAX_VALUE. 
HebbianSolver(double convergenceTarget,
int maxPassesPerEigen)
This is the recommended constructor to use if you're not sure
Creates a new HebbianSolver with the default
HebbianUpdater to do the updating work, and the default
AsyncEigenVerifier to check for convergence in a
(single) background thread. 
HebbianSolver(EigenUpdater updater,
SingularVectorVerifier verifier,
double convergenceTarget)
Creates a new HebbianSolver with maxPassesPerEigen = Integer.MAX_VALUE (i.e.

HebbianSolver(EigenUpdater updater,
SingularVectorVerifier verifier,
double convergenceTarget,
int maxPassesPerEigen)
Creates a new HebbianSolver

HebbianSolver(int numPassesPerEigen)
Creates a new HebbianSolver with the default
HebbianUpdater to do the updating work, and the default
AsyncEigenVerifier to check for convergence in a (single)
background thread, with
convergenceTarget set to 0, which means that the solver will not really care about convergence as a loopexiting
criterion (but will be checking for convergence anyways, so it will be logged and singular values will be
saved). 
Modifier and Type  Method and Description 

protected boolean 
hasNotConverged(Vector currentPseudoEigen,
Matrix corpus,
TrainingState state)
Uses the
SingularVectorVerifier to check for convergence 
static void 
main(String[] args) 
TrainingState 
solve(Matrix corpus,
int desiredRank)
Primary singular vector solving method.

protected EigenStatus 
verify(Matrix corpus,
Vector currentPseudoEigen) 
public HebbianSolver(EigenUpdater updater, SingularVectorVerifier verifier, double convergenceTarget, int maxPassesPerEigen)
updater
 EigenUpdater
used to do the actual work of iteratively updating the current "best guess"
singular vector one datapoint presentation at a time.verifier
 SingularVectorVerifier
an object which perpetually tries to check how close to
convergence the current singular vector is (typically is a
AsyncEigenVerifier
which does this
in the background in another thread, while the main thread continues to converge)convergenceTarget
 a small "epsilon" value which tells the solver how small you want the cosine of the
angle between a proposed eigenvector and that same vector after being multiplied by the (square of the) input
corpusmaxPassesPerEigen
 a cutoff which tells the solver after how many times of checking for convergence (done
by the verifier) should the solver stop trying, even if it has not reached the convergenceTarget.public HebbianSolver(EigenUpdater updater, SingularVectorVerifier verifier, double convergenceTarget)
updater
 EigenUpdater
used to do the actual work of iteratively updating the current "best guess"
singular vector one datapoint presentation at a time.verifier
 SingularVectorVerifier
an object which perpetually tries to check how close to
convergence the current singular vector is (typically is a
AsyncEigenVerifier
which does this
in the background in another thread, while the main thread continues to converge)convergenceTarget
 a small "epsilon" value which tells the solver how small you want the cosine of the
angle between a proposed eigenvector and that same vector after being multiplied by the (square of the) input
corpuspublic HebbianSolver(double convergenceTarget, int maxPassesPerEigen)
HebbianUpdater
to do the updating work, and the default
AsyncEigenVerifier
to check for convergence in a
(single) background thread.convergenceTarget
 a small "epsilon" value which tells the solver how small you want the cosine of the
angle between a proposed eigenvector and that same vector after being multiplied by the (square of the) input
corpusmaxPassesPerEigen
 a cutoff which tells the solver after how many times of checking for convergence (done
by the verifier) should the solver stop trying, even if it has not reached the convergenceTarget.public HebbianSolver(double convergenceTarget)
HebbianUpdater
to do the updating work, and the default
AsyncEigenVerifier
to check for convergence in a (single)
background thread, with
maxPassesPerEigen set to Integer.MAX_VALUE. Not recommended unless only looking
for the first few (5, maybe 10?) singular
vectors, as small errors which compound early on quickly put a minimum error on subsequent vectors.convergenceTarget
 a small "epsilon" value which tells the solver how small you want the cosine of the
angle between a proposed eigenvector and that same vector after being multiplied by the (square of the) input
corpuspublic HebbianSolver(int numPassesPerEigen)
HebbianUpdater
to do the updating work, and the default
AsyncEigenVerifier
to check for convergence in a (single)
background thread, with
convergenceTarget set to 0, which means that the solver will not really care about convergence as a loopexiting
criterion (but will be checking for convergence anyways, so it will be logged and singular values will be
saved).numPassesPerEigen
 the exact number of times the verifier will check convergence status in the background
before the solver will move on to the next eigenvector.public TrainingState solve(Matrix corpus, int desiredRank)
corpus
 input matrix to find singular vectors of. Needs not be symmetric, should probably be sparse (in
fact the input vectors are not mutated, and accessed only via dotproducts and sums, so they should be
SequentialAccessSparseVector
desiredRank
 the number of singular vectors to find (in roughly decreasing order by singular value)TrainingState
of the solver, after desiredRank singular vectors (and approximate
singular values) have been found.protected boolean hasNotConverged(Vector currentPseudoEigen, Matrix corpus, TrainingState state)
SingularVectorVerifier
to check for convergencecurrentPseudoEigen
 the purported singular vector whose convergence is being checkedcorpus
 the corpus to check againststate
 contains the previous eigens, various other solving state TrainingState
protected EigenStatus verify(Matrix corpus, Vector currentPseudoEigen)
public static void main(String[] args)
Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.