@CodeReview(reviewer="Kevin R. Dixon", date="2008-07-23", changesNeeded=false, comments={"Added PublicationReference to Sanger\'s master\'s thesis.","Minor changes to javadoc.","Looks fine."}) @PublicationReference(author="Terrence D. Sanger", title="Optimal Unsupervised Learning in a Single-Layer Linear Feedforward Neural Network", type=Thesis, year=1989, url="http://ece-classweb.ucsd.edu/winter06/ece173/documents/Sanger%201989%20--%20Optimal%20Unsupervised%20Learning%20in%20a%20Single-layer%20Linear%20FeedforwardNN.pdf") public class GeneralizedHebbianAlgorithm extends AbstractAnytimeBatchLearner<java.util.Collection<Vector>,PrincipalComponentsAnalysisFunction> implements PrincipalComponentsAnalysis, MeasurablePerformanceAlgorithm
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PERFORMANCE_NAME
The performance name is "Change".
|
data, keepGoing
maxIterations
DEFAULT_ITERATION, iteration
Constructor and Description |
---|
GeneralizedHebbianAlgorithm(int numComponents,
double learningRate,
int maxIterations,
double minChange)
Creates a new instance of GeneralizedHebbianAlgorithm
|
Modifier and Type | Method and Description |
---|---|
protected void |
cleanupAlgorithm()
Called to clean up the learning algorithm's state after learning has
finished.
|
GeneralizedHebbianAlgorithm |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
double |
getChange()
Gets the change in in the last completed step of the algorithm.
|
double |
getLearningRate()
Getter for learningRate
|
double |
getMinChange()
Getter for minChange
|
int |
getNumComponents()
Gets the number of components used in the PCA dimension reduction.
|
NamedValue<java.lang.Double> |
getPerformance()
Gets the name-value pair that describes the current performance of the
algorithm.
|
PrincipalComponentsAnalysisFunction |
getResult()
Gets the VectorFunction that maps from the input space to the reduced
output space of "getNumComponents" dimensions.
|
protected boolean |
initializeAlgorithm()
Called to initialize the learning algorithm's state based on the
data that is stored in the data field.
|
void |
setLearningRate(double learningRate)
Setter for learningRate
|
void |
setMinChange(double minChange)
Setter for minChange
|
void |
setNumComponents(int numComponents)
Setter for numComponents
|
protected void |
setResult(PrincipalComponentsAnalysisFunction result)
Setter for result
|
protected boolean |
step()
Called to take a single step of the learning algorithm.
|
getData, getKeepGoing, learn, setData, setKeepGoing, stop
getMaxIterations, isResultValid, setMaxIterations
addIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListeners
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
learn
getMaxIterations, setMaxIterations
addIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListener
isResultValid
public static final java.lang.String PERFORMANCE_NAME
public GeneralizedHebbianAlgorithm(int numComponents, double learningRate, int maxIterations, double minChange)
minChange
- Minimum change below which to stop iterating, greater than or equal to
zero, typically 1e-10numComponents
- Number of components to extract from the data, must be greater than zerolearningRate
- Learning rate, or step size, (0,1], typically ~0.1maxIterations
- Maximum number of iterations before stoppingpublic GeneralizedHebbianAlgorithm clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface CloneableSerializable
clone
in class AbstractAnytimeBatchLearner<java.util.Collection<Vector>,PrincipalComponentsAnalysisFunction>
protected boolean initializeAlgorithm()
AbstractAnytimeBatchLearner
initializeAlgorithm
in class AbstractAnytimeBatchLearner<java.util.Collection<Vector>,PrincipalComponentsAnalysisFunction>
protected void cleanupAlgorithm()
AbstractAnytimeBatchLearner
cleanupAlgorithm
in class AbstractAnytimeBatchLearner<java.util.Collection<Vector>,PrincipalComponentsAnalysisFunction>
protected boolean step()
AbstractAnytimeBatchLearner
step
in class AbstractAnytimeBatchLearner<java.util.Collection<Vector>,PrincipalComponentsAnalysisFunction>
public double getLearningRate()
public void setLearningRate(double learningRate)
learningRate
- Learning rate, or step size, (0,1], typically ~0.1public double getMinChange()
public void setMinChange(double minChange)
minChange
- Minimum change below which to stop iterating, greater than or equal to
zero, typically 1e-10public int getNumComponents()
PrincipalComponentsAnalysis
getNumComponents
in interface PrincipalComponentsAnalysis
public void setNumComponents(int numComponents)
numComponents
- Number of components to extract from the data, must be greater than zeropublic PrincipalComponentsAnalysisFunction getResult()
PrincipalComponentsAnalysis
getResult
in interface AnytimeAlgorithm<PrincipalComponentsAnalysisFunction>
getResult
in interface PrincipalComponentsAnalysis
protected void setResult(PrincipalComponentsAnalysisFunction result)
result
- Vector function that maps the input space onto a numComponents-dimension
Vector representing the directions of maximal variance (information
gain). The ith row in the matrix approximates the i-th column of the
"U" matrix of the Singular Value Decomposition.public double getChange()
public NamedValue<java.lang.Double> getPerformance()
MeasurablePerformanceAlgorithm
getPerformance
in interface MeasurablePerformanceAlgorithm