public class StochasticGradientDescent extends Learner
This algorithm's user-configurable parameters are stored in member fields of this class. They may
be set via either a constructor that names each parameter explicitly or a constructor that takes
an instance of Parameters
as input. The documentation in each member field in this class indicates the default
value of the associated parameter when using the former type of constructor. The documentation of
the associated member field in the
Parameters
class indicates the default value of the parameter when using the latter type of constructor.
Modifier and Type | Class and Description |
---|---|
static class |
StochasticGradientDescent.Parameters
Simply a container for all of
StochasticGradientDescent 's configurable parameters. |
Modifier and Type | Field and Description |
---|---|
protected double |
bias
The bias is stored here rather than as an element of the weight vector.
|
static double |
defaultLearningRate
Default value for
learningRate . |
static SparseWeightVector |
defaultWeightVector
Default for
weightVector . |
protected double |
learningRate
The rate at which weights are updated; default
defaultLearningRate . |
protected SparseWeightVector |
weightVector
The hypothesis vector; default
defaultWeightVector . |
candidates, encoding, extractor, labeler, labelLexicon, lcFilePath, lexFilePath, lexicon, lossFlag, predictions, readLexiconOnDemand
containingPackage, name
Constructor and Description |
---|
StochasticGradientDescent()
The learning rate takes the default value, while the name of the classifier gets the empty
string.
|
StochasticGradientDescent(double r)
Sets the learning rate to the specified value, while the name of the classifier gets the
empty string.
|
StochasticGradientDescent(StochasticGradientDescent.Parameters p)
Initializing constructor.
|
StochasticGradientDescent(String n)
The learning rate takes the default value.
|
StochasticGradientDescent(String n,
double r)
Use this constructor to specify an alternative subclass of
SparseWeightVector . |
StochasticGradientDescent(String n,
StochasticGradientDescent.Parameters p)
Initializing constructor.
|
Modifier and Type | Method and Description |
---|---|
FeatureVector |
classify(int[] exampleFeatures,
double[] exampleValues)
Simply computes the dot product of the weight vector and the feature vector extracted from
the example object.
|
Object |
clone()
Returns a deep clone of this learning algorithm.
|
Feature |
featureValue(int[] f,
double[] v)
Returns the classification of the given example as a single feature instead of a
FeatureVector . |
void |
forget()
Resets the weight vector to all zeros.
|
double |
getLearningRate()
Returns the current value of the
learningRate variable. |
String |
getOutputType()
Returns a string describing the output feature type of this classifier.
|
Learner.Parameters |
getParameters()
Retrieves the parameters that are set in this learner.
|
void |
learn(int[] exampleFeatures,
double[] exampleValues,
int[] exampleLabels,
double[] labelValues)
Trains the learning algorithm given an object as an example.
|
void |
read(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessInputStream in)
Reads the binary representation of a learner with this object's run-time type, overwriting
any and all learned or manually specified parameters as well as the label lexicon but without
modifying the feature lexicon.
|
double |
realValue(int[] exampleFeatures,
double[] exampleValues)
Simply computes the dot product of the weight vector and the example
|
ScoreSet |
scores(int[] exampleFeatures,
double[] exampleValues)
Since this algorithm returns a real feature, it does not return scores.
|
void |
setLearningRate(double t)
Sets the
learningRate member variable to the specified value. |
void |
setParameters(StochasticGradientDescent.Parameters p)
Sets the values of parameters that control the behavior of this learning algorithm.
|
void |
write(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out)
Writes the learned function's internal representation in binary form.
|
void |
write(PrintStream out)
Writes the algorithm's internal representation as text.
|
classify, classify, classify, classify, countFeatures, createPrediction, createPrediction, demandLexicon, discreteValue, discreteValue, discreteValue, doneLearning, doneWithRound, emptyClone, featureValue, featureValue, getCurrentLexicon, getExampleArray, getExampleArray, getExtractor, getLabeler, getLabelLexicon, getLexicon, getLexiconDiscardCounts, getLexiconLocation, getModelLocation, getPrunedLexiconSize, initialize, learn, learn, learn, learn, read, readLabelLexicon, readLearner, readLearner, readLearner, readLearner, readLearner, readLearner, readLexicon, readLexicon, readLexiconOnDemand, readLexiconOnDemand, readModel, readModel, readParameters, realValue, realValue, save, saveLexicon, saveModel, scores, scores, scoresAugmented, setCandidates, setEncoding, setExtractor, setLabeler, setLabelLexicon, setLexicon, setLexiconLocation, setLexiconLocation, setLossFlag, setModelLocation, setModelLocation, setParameters, setReadLexiconOnDemand, unclone, unsetLossFlag, write, writeLexicon, writeModel, writeParameters
allowableValues, classify, discreteValueArray, getCompositeChildren, getInputType, realValueArray, test, toString, valueIndexOf
public static final double defaultLearningRate
learningRate
.public static final SparseWeightVector defaultWeightVector
weightVector
.protected SparseWeightVector weightVector
defaultWeightVector
.protected double bias
protected double learningRate
defaultLearningRate
.public StochasticGradientDescent()
public StochasticGradientDescent(double r)
r
- The desired learning rate value.public StochasticGradientDescent(StochasticGradientDescent.Parameters p)
StochasticGradientDescent.Parameters
object.p
- The settings of all parameters.public StochasticGradientDescent(String n)
n
- The name of the classifier.public StochasticGradientDescent(String n, double r)
SparseWeightVector
.n
- The name of the classifier.r
- The desired learning rate value.public StochasticGradientDescent(String n, StochasticGradientDescent.Parameters p)
StochasticGradientDescent.Parameters
object.n
- The name of the classifier.p
- The settings of all parameters.public void setParameters(StochasticGradientDescent.Parameters p)
p
- The parameters.public Learner.Parameters getParameters()
getParameters
in class Learner
public double getLearningRate()
learningRate
variable.learningRate
variable.public void setLearningRate(double t)
learningRate
member variable to the specified value.t
- The new value for learningRate
.public void forget()
public String getOutputType()
getOutputType
in class Classifier
"real"
public void learn(int[] exampleFeatures, double[] exampleValues, int[] exampleLabels, double[] labelValues)
public ScoreSet scores(int[] exampleFeatures, double[] exampleValues)
public Feature featureValue(int[] f, double[] v)
FeatureVector
.featureValue
in class Learner
f
- The features array.v
- The values array.public double realValue(int[] exampleFeatures, double[] exampleValues)
public FeatureVector classify(int[] exampleFeatures, double[] exampleValues)
public void write(PrintStream out)
learningRate
and bias
.public void write(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out)
public void read(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessInputStream in)
Copyright © 2016. All rights reserved.