Examples of SignedValue


Examples of joshua.discriminative.semiring_parsing.SignedValue

    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{
View Full Code Here

Examples of joshua.discriminative.semiring_parsingv2.SignedValue


public class ScalarBO implements BilinearOperator<ScalarPM, ScalarPM, ScalarPM>{

  public ScalarPM bilinearMulti(ScalarPM r, ScalarPM s) {
    SignedValue res = SignedValue.multi(r.getValue(), s.getValue() );
    return new ScalarPM(res);
  }
View Full Code Here

Examples of joshua.discriminative.semiring_parsingv2.SignedValue

 
  SignedValue entropy;
  SignedValue risk;
 
  public RiskAndEntropyPM(){
    this.value = new SignedValue();
    this.entropy = new SignedValue();
    this.risk = new SignedValue();
  }
View Full Code Here

Examples of joshua.discriminative.semiring_parsingv2.SignedValue

    this.entropy = entropy;
    this.risk = risk;
  }
 
  public RiskAndEntropyPM duplicate() {
    SignedValue v = this.value.duplicate();
    SignedValue e = this.entropy.duplicate();
    SignedValue r = this.risk.duplicate();
    return new RiskAndEntropyPM(v,e,r);
  }
View Full Code Here

Examples of joshua.discriminative.semiring_parsingv2.SignedValue

    //goalX.printInfor();
 
   
    //=== entropy
    //--normalize
    SignedValue entropyFactor = goalK.getR().getEntropy().duplicate();
    entropyFactor.multiLogNumber(-logZ);
   
    this.entropy = logZ - entropyFactor.convertToRealValue();//logZ - \bar{r}/Z
    //System.out.print("Entropy is" + entropy);
   
    //=== risk
    //--normalize
    SignedValue riskFactor = goalK.getR().getRisk().duplicate();
    riskFactor.multiLogNumber(-logZ);
    this.risk =  riskFactor.convertToRealValue();
    //System.out.print("Risk is" + risk);
   
    this.functionValue = this.risk - this.temperature*this.entropy;
   
   
    //=== gradients
    //System.out.print("Gradients are: ");
    HashMap<Integer, Double>  gradient = new HashMap<Integer, Double>();
    for(Integer featID : goalX.getT().getValue().getIds()){
      //delta(r)*Z/Z^2=delta(r)/Z
      //--normalize
      SignedValue resT = goalX.getT().getValue().getValueAt(featID).duplicate();
      resT.multiLogNumber(-logZ);
       
      //-delta(Z)*r/Z^2
      SignedValue resRS = SignedValue.multi(
          goalX.getS().getValue().getValueAt(featID),
          goalK.getR().getValue()
        );
      resRS.negate();
      resRS.multiLogNumber(-2*logZ);
     
      //-T*delta(Z)/Z
      SignedValue resS = goalX.getS().getValue().getValueAt(featID).duplicate();
      resS.multiLogNumber(Math.log(this.getTemperature()));
      resS.negate();     
      resS.multiLogNumber(-logZ);
     
      //add them together
      resT.add(resRS);
      resT.add(resS);
      double finalVal = resT.convertToRealValue();
View Full Code Here

Examples of joshua.discriminative.semiring_parsingv2.SignedValue

public class ScalarPM implements PModule<LogSemiring, ScalarPM>{
 
  SignedValue value;
 
  public ScalarPM(){
    this.value = new SignedValue();
    this.value.setToZero();
  }
View Full Code Here

Examples of joshua.discriminative.semiring_parsingv2.SignedValue

  public ScalarPM(SignedValue v_){
    this.value = v_;
  }
 
  public ScalarPM duplicate() {
    SignedValue v = this.value.duplicate();
    return new ScalarPM(v);
  }
View Full Code Here

Examples of joshua.discriminative.semiring_parsingv2.SignedValue

  }*/
 

  public void add(SparseMap b) {
    for(Map.Entry<Integer, SignedValue> feature : b.tbl.entrySet()){
      SignedValue valB = feature.getValue();
      SignedValue valA = this.tbl.get(feature.getKey());
      if(valA!=null){
        valA.add(valB);
      }else{
        this.tbl.put(feature.getKey(), SignedValue.duplicate(valB));
      }
    }     
  }
View Full Code Here

Examples of joshua.discriminative.semiring_parsingv2.SignedValue

  }

  public SparseMap duplicate() {
    HashMap<Integer, SignedValue> res = new HashMap<Integer, SignedValue>();
    for(Map.Entry<Integer, SignedValue> feature : this.tbl.entrySet()){
      SignedValue val = feature.getValue().duplicate();
      res.put(feature.getKey(), val);
    }
    return new SparseMap(res);
  }
View Full Code Here

Examples of joshua.discriminative.semiring_parsingv2.SignedValue

    HashMap<Integer, SignedValue> gradientsMap = new HashMap<Integer, SignedValue>();    
    for(Map.Entry<Integer, Double> feature : features.entrySet()){
      int featID = feature.getKey();
     
      //P_e * \gamma * \Phi(e)
      SignedValue logGradient = SignedValue.createSignedValueFromRealNumber( scale*feature.getValue() );
      logGradient.multiLogNumber(logTransitionProb);
     
      gradientsMap.put(featID, logGradient);
    }
   
    return new SparseMap(gradientsMap);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.