public CRFOptimizableByBatchLabelLikelihood(CRF crf, InstanceList ilist, int numBatches) { // set up this.crf = crf; this.trainingSet = ilist; this.numBatches = numBatches; cachedValue = new double[this.numBatches]; cachedGradient = new ArrayList<double[]>(this.numBatches); expectations = new ArrayList<CRF.Factors>(this.numBatches); int numFactors = crf.parameters.getNumFactors(); for (int i = 0; i < this.numBatches; ++i) { cachedGradient.add(new double[numFactors]); expectations.add(new CRF.Factors(crf.parameters)); } constraints = new CRF.Factors(crf.parameters); gatherConstraints(ilist); }
public CRFOptimizableByBatchLabelLikelihood(CRF crf, InstanceList ilist, int numBatches) { // set up this.crf = crf; this.trainingSet = ilist; this.numBatches = numBatches; cachedValue = new double[this.numBatches]; cachedGradient = new ArrayList<double[]>(this.numBatches); expectations = new ArrayList<CRF.Factors>(this.numBatches); int numFactors = crf.parameters.getNumFactors(); for (int i = 0; i < this.numBatches; ++i) { cachedGradient.add(new double[numFactors]); expectations.add(new CRF.Factors(crf.parameters)); } constraints = new CRF.Factors(crf.parameters); gatherConstraints(ilist); }
public CRFOptimizableByBatchLabelLikelihood(CRF crf, InstanceList ilist, int numBatches) { // set up this.crf = crf; this.trainingSet = ilist; this.numBatches = numBatches; cachedValue = new double[this.numBatches]; cachedGradient = new ArrayList<double[]>(this.numBatches); expectations = new ArrayList<CRF.Factors>(this.numBatches); int numFactors = crf.parameters.getNumFactors(); for (int i = 0; i < this.numBatches; ++i) { cachedGradient.add(new double[numFactors]); expectations.add(new CRF.Factors(crf.parameters)); } constraints = new CRF.Factors(crf.parameters); gatherConstraints(ilist); }
public CRFOptimizableByGE(CRF crf, ArrayList<GEConstraint> constraints, InstanceList data, StateLabelMap map, int numThreads, double weight) { this.crf = crf; this.constraints = constraints; this.cache = Integer.MAX_VALUE; this.cachedValue = Double.NaN; this.cachedGradient = new CRF.Factors(crf); this.data = data; this.numThreads = numThreads; this.weight = weight; instancesWithConstraints = new BitSet(data.size()); for (GEConstraint constraint : constraints) { constraint.setStateLabelMap(map); BitSet bitset = constraint.preProcess(data); instancesWithConstraints.or(bitset); } this.gpv = DEFAULT_GPV; if (numThreads > 1) { this.executor = (ThreadPoolExecutor)Executors.newFixedThreadPool(numThreads); } createReverseTransitionMatrices(crf); }
public CRFOptimizableByGE(CRF crf, ArrayList<GEConstraint> constraints, InstanceList data, StateLabelMap map, int numThreads, double weight) { this.crf = crf; this.constraints = constraints; this.cache = Integer.MAX_VALUE; this.cachedValue = Double.NaN; this.cachedGradient = new CRF.Factors(crf); this.data = data; this.numThreads = numThreads; this.weight = weight; instancesWithConstraints = new BitSet(data.size()); for (GEConstraint constraint : constraints) { constraint.setStateLabelMap(map); BitSet bitset = constraint.preProcess(data); instancesWithConstraints.or(bitset); } this.gpv = DEFAULT_GPV; if (numThreads > 1) { this.executor = (ThreadPoolExecutor)Executors.newFixedThreadPool(numThreads); } createReverseTransitionMatrices(crf); }
public CRFOptimizableByLabelLikelihood (CRF crf, InstanceList ilist) { // Set up this.crf = crf; this.trainingSet = ilist; //cachedGradient = new DenseVector (numParameters); cachedGradient = new double[crf.parameters.getNumFactors()]; constraints = new CRF.Factors(crf.parameters); expectations = new CRF.Factors(crf.parameters); // This resets and values that may have been in expectations and constraints //reallocateSufficientStatistics(); // This is unfortunately necessary, b/c cachedValue & cachedValueStale not in same place! cachedValueWeightsStamp = -1; cachedGradientWeightsStamp = -1; gatherConstraints (ilist); }
public CRFOptimizableByLabelLikelihood (CRF crf, InstanceList ilist) { // Set up this.crf = crf; this.trainingSet = ilist; //cachedGradient = new DenseVector (numParameters); cachedGradient = new double[crf.parameters.getNumFactors()]; constraints = new CRF.Factors(crf.parameters); expectations = new CRF.Factors(crf.parameters); // This resets and values that may have been in expectations and constraints //reallocateSufficientStatistics(); // This is unfortunately necessary, b/c cachedValue & cachedValueStale not in same place! cachedValueWeightsStamp = -1; cachedGradientWeightsStamp = -1; gatherConstraints (ilist); }
public CRFOptimizableByLabelLikelihood (CRF crf, InstanceList ilist) { // Set up this.crf = crf; this.trainingSet = ilist; //cachedGradient = new DenseVector (numParameters); cachedGradient = new double[crf.parameters.getNumFactors()]; constraints = new CRF.Factors(crf.parameters); expectations = new CRF.Factors(crf.parameters); // This resets and values that may have been in expectations and constraints //reallocateSufficientStatistics(); // This is unfortunately necessary, b/c cachedValue & cachedValueStale not in same place! cachedValueWeightsStamp = -1; cachedGradientWeightsStamp = -1; gatherConstraints (ilist); }
/** * Initializes the structures. */ public CRFOptimizableByEntropyRegularization(CRF crf, InstanceList ilist, double scalingFactor) { data = ilist; this.crf = crf; this.scalingFactor = scalingFactor; // initialize the expectations using the model expectations = new CRF.Factors(crf); incrementor = expectations.new Incrementor(); cachedValue = 0.0; cachedGradient = new double[crf.getParameters().getNumFactors()]; }
/** * Initializes the structures. */ public CRFOptimizableByEntropyRegularization(CRF crf, InstanceList ilist, double scalingFactor) { data = ilist; this.crf = crf; this.scalingFactor = scalingFactor; // initialize the expectations using the model expectations = new CRF.Factors(crf); incrementor = expectations.new Incrementor(); cachedValue = 0.0; cachedGradient = new double[crf.getParameters().getNumFactors()]; }
/** * Initializes the structures. */ public CRFOptimizableByEntropyRegularization(CRF crf, InstanceList ilist, double scalingFactor) { data = ilist; this.crf = crf; this.scalingFactor = scalingFactor; // initialize the expectations using the model expectations = new CRF.Factors(crf); incrementor = expectations.new Incrementor(); cachedValue = 0.0; cachedGradient = new double[crf.getParameters().getNumFactors()]; }
public CRFTrainerByStochasticGradient(CRF crf, InstanceList trainingSample) { this.crf = crf; this.expectations = new CRF.Factors(crf); this.constraints = new CRF.Factors(crf); this.setLearningRateByLikelihood(trainingSample); }
public CRFTrainerByStochasticGradient(CRF crf, InstanceList trainingSample) { this.crf = crf; this.expectations = new CRF.Factors(crf); this.constraints = new CRF.Factors(crf); this.setLearningRateByLikelihood(trainingSample); }
protected MEMMOptimizableByLabelLikelihood (MEMM memm, InstanceList trainingData) { super (memm, trainingData); expectations = new CRF.Factors (memm); constraints = new CRF.Factors (memm); }
public CRFTrainerByStochasticGradient(CRF crf, double learningRate) { this.crf = crf; this.learningRate = learningRate; this.expectations = new CRF.Factors(crf); this.constraints = new CRF.Factors(crf); }
protected MEMMOptimizableByLabelLikelihood (MEMM memm, InstanceList trainingData) { super (memm, trainingData); expectations = new CRF.Factors (memm); constraints = new CRF.Factors (memm); }
public CRFTrainerByStochasticGradient(CRF crf, double learningRate) { this.crf = crf; this.learningRate = learningRate; this.expectations = new CRF.Factors(crf); this.constraints = new CRF.Factors(crf); }
public CRFTrainerByStochasticGradient(CRF crf, double learningRate) { this.crf = crf; this.learningRate = learningRate; this.expectations = new CRF.Factors(crf); this.constraints = new CRF.Factors(crf); }
protected MEMMOptimizableByLabelLikelihood (MEMM memm, InstanceList trainingData) { super (memm, trainingData); expectations = new CRF.Factors (memm); constraints = new CRF.Factors (memm); }
public CRFTrainerByStochasticGradient(CRF crf, InstanceList trainingSample) { this.crf = crf; this.expectations = new CRF.Factors(crf); this.constraints = new CRF.Factors(crf); this.setLearningRateByLikelihood(trainingSample); }