tuffy.learn
Class DNLearner

java.lang.Object
  extended by tuffy.main.Infer
      extended by tuffy.learn.Learner
          extended by tuffy.learn.DNLearner

public class DNLearner
extends Learner

Learner instance using diagonal Newton with dynamic step size. Method used here follows: Lowd, Daniel and Domingos, Pedro (2007). Efficient Weight Learning for Markov Logic Networks.

Author:
Ce Zhang

Field Summary
 double alpha
          Step size.
 java.util.HashMap<java.lang.String,java.lang.Double> currentD
          Map from clause ID to current H^(-1)g value.
 java.util.HashMap<java.lang.String,java.lang.Double> currentGradient
          Map from clause ID to current gradient value.
 double lambda
          Lambda used to control the step size.
 int nCall
          Number of invocations of DNLearner#updateWeight(MCSAT).
 java.util.HashMap<java.lang.String,java.lang.Double> oldD
          Map from clause ID to H^(-1)g value in last iteration.
 double oldDG
          D'g value of last iteration.
 double oldDHD
          D'HD value of last iteration.
 java.util.HashMap<java.lang.String,java.lang.Double> oldG
          Map from clause ID to gradient value in last iteration.
 java.util.HashMap<java.lang.String,java.lang.Double> oldWeight
          Map from clause ID to weight in last iteration.
 
Fields inherited from class tuffy.learn.Learner
_oldWeight, backtrackCount_, backtracked, currentWeight, finalWeight, isHardMappings, negativeWeightSatisfication, negativeWeightViolation, odds, oriWeight, positiveWeightSatisfication, positiveWeightViolation, trainingSatisification, trainingViolation
 
Fields inherited from class tuffy.main.Infer
db, dmover, grounding, mln, options
 
Constructor Summary
DNLearner()
           
 
Method Summary
 void getGradientAndD(MRF mcsat)
          Calculate the gradient and H^(-1)g by filling in currentD and currentGradient.
 void loadingTrainingData(MRF _mcsat)
          Load training data's truth value into MRF.
 boolean updateWeight(MRF mcsat)
          Update Learner.currentWeight using Diagonal Newton method.
 
Methods inherited from class tuffy.learn.Learner
calcCurrentTrainingViolation, dumpAnswers, fillInCurrentWeight, run
 
Methods inherited from class tuffy.main.Infer
cleanUp, ground, loadMLN, setUp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

oldG

public java.util.HashMap<java.lang.String,java.lang.Double> oldG
Map from clause ID to gradient value in last iteration.


oldD

public java.util.HashMap<java.lang.String,java.lang.Double> oldD
Map from clause ID to H^(-1)g value in last iteration.


oldWeight

public java.util.HashMap<java.lang.String,java.lang.Double> oldWeight
Map from clause ID to weight in last iteration. It is used for backtracking.


currentGradient

public java.util.HashMap<java.lang.String,java.lang.Double> currentGradient
Map from clause ID to current gradient value. This will be filled after the invocation of DNLearner#getGradientAndD(MCSAT).


currentD

public java.util.HashMap<java.lang.String,java.lang.Double> currentD
Map from clause ID to current H^(-1)g value. This will be filled after the invocation of DNLearner#getGradientAndD(MCSAT).


oldDHD

public double oldDHD
D'HD value of last iteration. Here D = H^(-1)g, H is Hessian.


oldDG

public double oldDG
D'g value of last iteration. Here D = H^(-1)g.


lambda

public double lambda
Lambda used to control the step size.


alpha

public double alpha
Step size.


nCall

public int nCall
Number of invocations of DNLearner#updateWeight(MCSAT).

Constructor Detail

DNLearner

public DNLearner()
Method Detail

loadingTrainingData

public void loadingTrainingData(MRF _mcsat)
Load training data's truth value into MRF.

Specified by:
loadingTrainingData in class Learner
Parameters:
_mcsat - The MCSAT object to be filled in.

getGradientAndD

public void getGradientAndD(MRF mcsat)
Calculate the gradient and H^(-1)g by filling in currentD and currentGradient.

Parameters:
mcsat - MCSAT instance used to estimate the expectation of violations.

updateWeight

public boolean updateWeight(MRF mcsat)
Update Learner.currentWeight using Diagonal Newton method.

Specified by:
updateWeight in class Learner
Parameters:
mcsat - MCSAT instance after this iteration.
Returns:
true if it wants the learner to terminate iterations. This may happen when converge.