public class Classifier
extends java.lang.Object
In order to train a classifier, instantiate this class using the
#Classifier(Config, Dataset, double[][], double[][], double[], double[][], java.util.List)
constructor. (The presence of a non-null dataset signals that we
wish to train.) After training by alternating calls to
computeCostFunction(int, double, double)
and,
takeAdaGradientStep(edu.stanford.nlp.parser.nndep.Classifier.Cost, double, double)
,
be sure to call finalizeTraining()
in order to allow the
classifier to clean up resources used during training.
Modifier and Type | Class and Description |
---|---|
class |
Classifier.Cost
Describes the result of feedforward + backpropagation through
the neural network for the batch provided to a `CostFunction.`
|
Constructor and Description |
---|
Classifier(Config config,
Dataset dataset,
float[][] E,
float[][] W1,
float[] b1,
float[][] W2,
java.util.List<java.lang.Integer> preComputed)
Instantiate a classifier with training data and randomly
initialized parameter matrices in order to begin training.
|
Classifier(Config config,
float[][] E,
float[][] W1,
float[] b1,
float[][] W2,
java.util.List<java.lang.Integer> preComputed)
Instantiate a classifier with previously learned parameters in
order to perform new inference.
|
Modifier and Type | Method and Description |
---|---|
void |
clearGradientHistories()
Clear all gradient histories used for AdaGrad training.
|
Classifier.Cost |
computeCostFunction(int batchSize,
double regParameter,
double dropOutProb)
Determine the total cost on the dataset associated with this
classifier using the current learned parameters.
|
void |
finalizeTraining()
Finish training this classifier; prepare for a shutdown.
|
float[] |
getb1() |
float[][] |
getE() |
float[][] |
getW1() |
float[][] |
getW2() |
void |
preCompute() |
void |
preCompute(java.util.Set<java.lang.Integer> toPreCompute)
Pre-compute hidden layer activations for some set of possible
feature inputs.
|
void |
takeAdaGradientStep(Classifier.Cost cost,
double adaAlpha,
double adaEps)
Update classifier weights using the given training cost
information.
|
public Classifier(Config config, float[][] E, float[][] W1, float[] b1, float[][] W2, java.util.List<java.lang.Integer> preComputed)
config
- E
- W1
- b1
- W2
- preComputed
- public Classifier(Config config, Dataset dataset, float[][] E, float[][] W1, float[] b1, float[][] W2, java.util.List<java.lang.Integer> preComputed)
config
- dataset
- E
- W1
- b1
- W2
- preComputed
- public Classifier.Cost computeCostFunction(int batchSize, double regParameter, double dropOutProb)
batchSize
- regParameter
- Regularization parameter (lambda)dropOutProb
- Drop-out probability. Hidden-layer units in the
neural network will be randomly turned off
while training a particular example with this
probability.Classifier.Cost
object which describes the total cost of the given
weights, and includes gradients to be used for further
trainingpublic void takeAdaGradientStep(Classifier.Cost cost, double adaAlpha, double adaEps)
cost
- Cost information as returned by
computeCostFunction(int, double, double)
.adaAlpha
- Global AdaGrad learning rateadaEps
- Epsilon value for numerical stability in AdaGrad's
divisionpublic void clearGradientHistories()
java.lang.IllegalStateException
- If not trainingpublic void finalizeTraining()
public void preCompute()
preCompute(java.util.Set)
public void preCompute(java.util.Set<java.lang.Integer> toPreCompute)
toPreCompute
- Set of feature IDs for which hidden layer
activations should be precomputedpublic float[][] getW1()
public float[] getb1()
public float[][] getW2()
public float[][] getE()