/** Returns the log probability of the training sequence labels and the prior over parameters. */ public double getValue () { if (crf.weightsValueChangeStamp != cachedValueWeightsStamp) { // The cached value is not up to date; it was calculated for a different set of CRF weights. cachedValueWeightsStamp = crf.weightsValueChangeStamp; // cachedValue will soon no longer be stale long startingTime = System.currentTimeMillis(); //crf.print(); // Get the value of all the all the true labels, also filling in expectations at the same time. cachedValue = getExpectationValue (); // Incorporate prior on parameters if (usingHyperbolicPrior) // Hyperbolic prior cachedValue += crf.parameters.hyberbolicPrior(hyperbolicPriorSlope, hyperbolicPriorSharpness); else // Gaussian prior cachedValue += crf.parameters.gaussianPrior(gaussianPriorVariance); // gsc: make sure the prior gives a correct value assert(!(Double.isNaN(cachedValue) || Double.isInfinite(cachedValue))) : "Label likelihood is NaN/Infinite"; logger.info ("getValue() (loglikelihood, optimizable by label likelihood) = "+cachedValue); long endingTime = System.currentTimeMillis(); logger.fine ("Inference milliseconds = "+(endingTime - startingTime)); } return cachedValue; }
public double getValue() { if (crf.getWeightsValueChangeStamp() != cachedValueWeightsStamp) { cachedValueWeightsStamp = crf.getWeightsValueChangeStamp(); long startingTime = System.currentTimeMillis(); cachedValue = getExpectationValue(); // Incorporate prior on parameters double priorValue = crf.getParameters().gaussianPrior(gaussianPriorVariance); cachedValue += priorValue; logger.info("Gaussian prior = " + priorValue); cachedValue *= weight; assert (!(Double.isNaN(cachedValue) || Double.isInfinite(cachedValue))) : "Label likelihood is NaN/Infinite"; logger.info("getValue() (loglikelihood, optimizable by klDiv) = "+ cachedValue); long endingTime = System.currentTimeMillis(); logger.fine("Inference milliseconds = " + (endingTime - startingTime)); } return cachedValue; }
/** Returns the log probability of the training sequence labels and the prior over parameters. */ public double getValue () { if (crf.weightsValueChangeStamp != cachedValueWeightsStamp) { // The cached value is not up to date; it was calculated for a different set of CRF weights. cachedValueWeightsStamp = crf.weightsValueChangeStamp; // cachedValue will soon no longer be stale long startingTime = System.currentTimeMillis(); //crf.print(); // Get the value of all the all the true labels, also filling in expectations at the same time. cachedValue = getExpectationValue (); // Incorporate prior on parameters if (usingHyperbolicPrior) // Hyperbolic prior cachedValue += crf.parameters.hyberbolicPrior(hyperbolicPriorSlope, hyperbolicPriorSharpness); else // Gaussian prior cachedValue += crf.parameters.gaussianPrior(gaussianPriorVariance); // gsc: make sure the prior gives a correct value assert(!(Double.isNaN(cachedValue) || Double.isInfinite(cachedValue))) : "Label likelihood is NaN/Infinite"; logger.info ("getValue() (loglikelihood, optimizable by label likelihood) = "+cachedValue); long endingTime = System.currentTimeMillis(); logger.fine ("Inference milliseconds = "+(endingTime - startingTime)); } return cachedValue; }
this.cachedValue += crf.getParameters().gaussianPrior(gpv); cachedGradient.plusEqualsGaussianPriorGradient(crf.getParameters(), gpv);
this.cachedValue += crf.getParameters().gaussianPrior(gpv); cachedGradient.plusEqualsGaussianPriorGradient(crf.getParameters(), gpv);
this.cachedValue += crf.getParameters().gaussianPrior(gpv); cachedGradient.plusEqualsGaussianPriorGradient(crf.getParameters(), gpv);
/** * Returns the log probability of a batch of training sequence labels and the prior over * parameters, if last batch then incorporate the prior on parameters as well. */ public double getBatchValue(int batchIndex, int[] batchAssignments) { assert(batchIndex < this.numBatches) : "Incorrect batch index: " + batchIndex + ", range(0, " + this.numBatches + ")"; assert(batchAssignments.length == 2 && batchAssignments[0] <= batchAssignments[1]) : "Invalid batch assignments: " + Arrays.toString(batchAssignments); // Get the value of all the true labels for current batch, also filling in expectations double value = getExpectationValue(batchIndex, batchAssignments); if (batchIndex == numBatches-1) { if (usingHyperbolicPrior) // Hyperbolic prior value += crf.parameters.hyberbolicPrior(hyperbolicPriorSlope, hyperbolicPriorSharpness); else // Gaussian prior value += crf.parameters.gaussianPrior(gaussianPriorVariance); } assert(!(Double.isNaN(value) || Double.isInfinite(value))) : "Label likelihood is NaN/Infinite, batchIndex: " + batchIndex + "batchAssignments: " + Arrays.toString(batchAssignments); // update cache cachedValue[batchIndex] = value; return value; }
/** Returns the log probability of the training sequence labels and the prior over parameters. */ public double getValue () { if (crf.weightsValueChangeStamp != cachedValueWeightsStamp) { // The cached value is not up to date; it was calculated for a different set of CRF weights. cachedValueWeightsStamp = crf.weightsValueChangeStamp; // cachedValue will soon no longer be stale long startingTime = System.currentTimeMillis(); //crf.print(); // Get the value of all the all the true labels, also filling in expectations at the same time. cachedValue = getExpectationValue (); // Incorporate prior on parameters if (usingHyperbolicPrior) // Hyperbolic prior cachedValue += crf.parameters.hyberbolicPrior(hyperbolicPriorSlope, hyperbolicPriorSharpness); else // Gaussian prior cachedValue += crf.parameters.gaussianPrior(gaussianPriorVariance); // gsc: make sure the prior gives a correct value assert(!(Double.isNaN(cachedValue) || Double.isInfinite(cachedValue))) : "Label likelihood is NaN/Infinite"; logger.info ("getValue() (loglikelihood, optimizable by label likelihood) = "+cachedValue); long endingTime = System.currentTimeMillis(); logger.fine ("Inference milliseconds = "+(endingTime - startingTime)); } return cachedValue; }
/** * Returns the log probability of a batch of training sequence labels and the prior over * parameters, if last batch then incorporate the prior on parameters as well. */ public double getBatchValue(int batchIndex, int[] batchAssignments) { assert(batchIndex < this.numBatches) : "Incorrect batch index: " + batchIndex + ", range(0, " + this.numBatches + ")"; assert(batchAssignments.length == 2 && batchAssignments[0] <= batchAssignments[1]) : "Invalid batch assignments: " + Arrays.toString(batchAssignments); // Get the value of all the true labels for current batch, also filling in expectations double value = getExpectationValue(batchIndex, batchAssignments); if (batchIndex == numBatches-1) { if (usingHyperbolicPrior) // Hyperbolic prior value += crf.parameters.hyberbolicPrior(hyperbolicPriorSlope, hyperbolicPriorSharpness); else // Gaussian prior value += crf.parameters.gaussianPrior(gaussianPriorVariance); } assert(!(Double.isNaN(value) || Double.isInfinite(value))) : "Label likelihood is NaN/Infinite, batchIndex: " + batchIndex + "batchAssignments: " + Arrays.toString(batchAssignments); // update cache cachedValue[batchIndex] = value; return value; }
/** * Returns the log probability of a batch of training sequence labels and the prior over * parameters, if last batch then incorporate the prior on parameters as well. */ public double getBatchValue(int batchIndex, int[] batchAssignments) { assert(batchIndex < this.numBatches) : "Incorrect batch index: " + batchIndex + ", range(0, " + this.numBatches + ")"; assert(batchAssignments.length == 2 && batchAssignments[0] <= batchAssignments[1]) : "Invalid batch assignments: " + Arrays.toString(batchAssignments); // Get the value of all the true labels for current batch, also filling in expectations double value = getExpectationValue(batchIndex, batchAssignments); if (batchIndex == numBatches-1) { if (usingHyperbolicPrior) // Hyperbolic prior value += crf.parameters.hyberbolicPrior(hyperbolicPriorSlope, hyperbolicPriorSharpness); else // Gaussian prior value += crf.parameters.gaussianPrior(gaussianPriorVariance); } assert(!(Double.isNaN(value) || Double.isInfinite(value))) : "Label likelihood is NaN/Infinite, batchIndex: " + batchIndex + "batchAssignments: " + Arrays.toString(batchAssignments); // update cache cachedValue[batchIndex] = value; return value; }
public double getValue() { if (crf.getWeightsValueChangeStamp() != cachedValueWeightsStamp) { cachedValueWeightsStamp = crf.getWeightsValueChangeStamp(); long startingTime = System.currentTimeMillis(); cachedValue = getExpectationValue(); // Incorporate prior on parameters double priorValue = crf.getParameters().gaussianPrior(gaussianPriorVariance); cachedValue += priorValue; logger.info("Gaussian prior = " + priorValue); cachedValue *= weight; assert (!(Double.isNaN(cachedValue) || Double.isInfinite(cachedValue))) : "Label likelihood is NaN/Infinite"; logger.info("getValue() (loglikelihood, optimizable by klDiv) = "+ cachedValue); long endingTime = System.currentTimeMillis(); logger.fine("Inference milliseconds = " + (endingTime - startingTime)); } return cachedValue; }
public double getValue() { if (crf.getWeightsValueChangeStamp() != cachedValueWeightsStamp) { cachedValueWeightsStamp = crf.getWeightsValueChangeStamp(); long startingTime = System.currentTimeMillis(); cachedValue = getExpectationValue(); // Incorporate prior on parameters double priorValue = crf.getParameters().gaussianPrior(gaussianPriorVariance); cachedValue += priorValue; logger.info("Gaussian prior = " + priorValue); cachedValue *= weight; assert (!(Double.isNaN(cachedValue) || Double.isInfinite(cachedValue))) : "Label likelihood is NaN/Infinite"; logger.info("getValue() (loglikelihood, optimizable by klDiv) = "+ cachedValue); long endingTime = System.currentTimeMillis(); logger.fine("Inference milliseconds = " + (endingTime - startingTime)); } return cachedValue; }