public class PerceptronModel extends BaseModel
Constructor and Description |
---|
PerceptronModel(PerceptronModel other) |
PerceptronModel(ShiftReduceOptions op,
Index<Transition> transitionIndex,
java.util.Set<java.lang.String> knownStates,
java.util.Set<java.lang.String> rootStates,
java.util.Set<java.lang.String> rootOnlyStates) |
Modifier and Type | Method and Description |
---|---|
void |
averageModels(java.util.Collection<PerceptronModel> models) |
void |
averageScoredModels(java.util.Collection<ScoredObject<PerceptronModel>> scoredModels) |
java.util.Collection<ScoredObject<java.lang.Integer>> |
findHighestScoringTransitions(State state,
boolean requireLegal,
int numTransitions,
java.util.List<ParserConstraint> constraints) |
float |
maxAbs() |
int |
numWeights() |
void |
outputStats(TrainingResult result)
Output some random facts about the model and the training iteration
|
static PerceptronModel |
trainModel(ShiftReduceOptions op,
Index<Transition> transitionIndex,
java.util.Set<java.lang.String> knownStates,
java.util.Set<java.lang.String> rootStates,
java.util.Set<java.lang.String> rootOnlyStates,
PerceptronModel initialModel,
java.lang.String serializedPath,
Tagger tagger,
java.util.Random random,
java.util.List<TrainingExample> trainingData,
Treebank devTreebank,
int nThreads)
Will train the model on the given treebank, using devTreebank as
a dev set.
|
findEmergencyTransition
public PerceptronModel(ShiftReduceOptions op, Index<Transition> transitionIndex, java.util.Set<java.lang.String> knownStates, java.util.Set<java.lang.String> rootStates, java.util.Set<java.lang.String> rootOnlyStates)
public PerceptronModel(PerceptronModel other)
public void averageScoredModels(java.util.Collection<ScoredObject<PerceptronModel>> scoredModels)
public void averageModels(java.util.Collection<PerceptronModel> models)
public int numWeights()
public float maxAbs()
public void outputStats(TrainingResult result)
public java.util.Collection<ScoredObject<java.lang.Integer>> findHighestScoringTransitions(State state, boolean requireLegal, int numTransitions, java.util.List<ParserConstraint> constraints)
findHighestScoringTransitions
in class BaseModel
public static PerceptronModel trainModel(ShiftReduceOptions op, Index<Transition> transitionIndex, java.util.Set<java.lang.String> knownStates, java.util.Set<java.lang.String> rootStates, java.util.Set<java.lang.String> rootOnlyStates, PerceptronModel initialModel, java.lang.String serializedPath, Tagger tagger, java.util.Random random, java.util.List<TrainingExample> trainingData, Treebank devTreebank, int nThreads)
op
- The options used to initialize the parsertransitionIndex
- precalculated transitions from the training dataknownStates
- the states in the training datarootStates
- states which occur at the top of the treesrootOnlyStates
- states which ONLY occur at the top of the treesinitialModel
- if training a continuation, use this model as the starting pointserializedPath
- Where serialized models go. If the appropriate options are set, the method can use this to save intermediate models.tagger
- The tagger to use when evaluating devTreebank. TODO: it would make more sense for ShiftReduceParser to retag the trees firstrandom
- A random number generator to use for any random numbers. Useful to make sure results can be reproduced.trainingData
- The treebank to train from, along with lists of transitions that will reproduce the same trees.devTreebank
- a set of trees which can be used for dev testing (assuming the user provided a dev treebank)nThreads
- how many threads the model can use for training