Package joshua.discriminative.semiring_parsing

Examples of joshua.discriminative.semiring_parsing.ExpectationSemiring


    this.pFeatFunctions = pFeatFunctions;
    this.qFeatFunctions = qFeatFunctions;
  }

  protected ExpectationSemiring createNewSemiringMember() {
    return new ExpectationSemiring();
  }
View Full Code Here


  protected ExpectationSemiring createNewSemiringMember() {
    return new ExpectationSemiring();
  }
 
  protected ExpectationSemiring getHyperedgeSemiringWeight(HyperEdge dt, HGNode parent_item, double scale, AtomicSemiring p_atomic_semiring){
    ExpectationSemiring res = null;
    if(p_atomic_semiring.ATOMIC_SEMIRING==AtomicSemiring.LOG_SEMIRING){
      double logProbP = - scale * computeTransitionCost(parent_item, dt, pFeatFunctions);//from p
      double valQ = -  scale * computeTransitionCost(parent_item, dt, qFeatFunctions);//from q;//s(x,y); to compute E(s(x,y)); real semiring
     
      //double factor1 = Math.exp(logProbP)*valQ; //real semiring
      SignedValue factor1 =  SignedValue.multi(
          logProbP,
          SignedValue.createSignedValue(valQ)
      );
      res = new ExpectationSemiring(logProbP, factor1);
    }else{
      System.out.println("un-implemented atomic-semiring");
      System.exit(1);
    }
    return res;
View Full Code Here

      //###############semiring parsing
      parserEntropyP.insideEstimationOverHG(testHG);
      parserEntropyQ.insideEstimationOverHG(testHG);
      parserCrossentropyPQ.insideEstimationOverHG(testHG);
     
      ExpectationSemiring pGoalSemiring = (ExpectationSemiring) parserEntropyP.getGoalSemiringMember(testHG);
      ExpectationSemiring qGoalSemiring = (ExpectationSemiring) parserEntropyQ.getGoalSemiringMember(testHG);
      ExpectationSemiring pqGoalSemiring = (ExpectationSemiring) parserCrossentropyPQ.getGoalSemiringMember(testHG);
     
      pGoalSemiring.normalizeFactors();
      pGoalSemiring.printInfor();
      qGoalSemiring.normalizeFactors();
      qGoalSemiring.printInfor();
      pqGoalSemiring.normalizeFactors();
      pqGoalSemiring.printInfor();
     
     
      double entropyP = pGoalSemiring.getLogProb() - pGoalSemiring.getFactor1().convertRealValue();//logZ-E(s)??????????
      double entropyQ = qGoalSemiring.getLogProb() - qGoalSemiring.getFactor1().convertRealValue();//logZ-E(s)?????
      double crossEntropyPQ = qGoalSemiring.getLogProb()- pqGoalSemiring.getFactor1().convertRealValue();//logZ(q)-E(s)?????????
      double klPQ = -entropyP + crossEntropyPQ;
      if(klPQ<0){System.out.println("kl divergence is negative, must be wrong"); System.exit(1);}
      System.out.println("p_entropy=" + entropyP +"; "+"q_entropy=" + entropyQ +"; "+"pq_entropy=" + crossEntropyPQ +"; "+"pq_kl=" + klPQ);
    }   
  }
View Full Code Here

TOP

Related Classes of joshua.discriminative.semiring_parsing.ExpectationSemiring

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.