private int cliqueSizeFromInstance (InstanceList training) { int maxWeight = 0; for (int i = 0; i < training.size(); i++) { Instance instance = training.get (i); UnrolledGraph unrolled = new UnrolledGraph (instance, new Template[] { this }, null, false); for (Iterator it = unrolled.unrolledVarSetIterator (); it.hasNext();) { UnrolledVarSet clique = (UnrolledVarSet) it.next (); if (clique.tmpl == this) { int thisWeight = clique.weight (); if (thisWeight > maxWeight) { maxWeight = thisWeight; } } } } if (maxWeight == 0) logger.warning ("***ACRF: Don't know size of "+this+". Never needed in training data."); return maxWeight; }
private int cliqueSizeFromInstance (InstanceList training) { int maxWeight = 0; for (int i = 0; i < training.size(); i++) { Instance instance = training.get (i); UnrolledGraph unrolled = new UnrolledGraph (instance, new Template[] { this }, null, false); for (Iterator it = unrolled.unrolledVarSetIterator (); it.hasNext();) { UnrolledVarSet clique = (UnrolledVarSet) it.next (); if (clique.tmpl == this) { int thisWeight = clique.weight (); if (thisWeight > maxWeight) { maxWeight = thisWeight; } } } } if (maxWeight == 0) logger.warning ("***ACRF: Don't know size of "+this+". Never needed in training data."); return maxWeight; }
private int cliqueSizeFromInstance (InstanceList training) { int maxWeight = 0; for (int i = 0; i < training.size(); i++) { Instance instance = training.get (i); UnrolledGraph unrolled = new UnrolledGraph (instance, new Template[] { this }, null, false); for (Iterator it = unrolled.unrolledVarSetIterator (); it.hasNext();) { UnrolledVarSet clique = (UnrolledVarSet) it.next (); if (clique.tmpl == this) { int thisWeight = clique.weight (); if (thisWeight > maxWeight) { maxWeight = thisWeight; } } } } if (maxWeight == 0) logger.warning ("***ACRF: Don't know size of "+this+". Never needed in training data."); return maxWeight; }
private void checkCliqueSizeConsistent (InstanceList training) { int weight = -1; for (int i = 0; i < training.size(); i++) { Instance instance = training.get (i); UnrolledGraph unrolled = new UnrolledGraph (instance, new Template[] { this }, null, false); for (Iterator it = unrolled.unrolledVarSetIterator (); it.hasNext();) { UnrolledVarSet clique = (UnrolledVarSet) it.next (); if (clique.tmpl == this) { if (weight != clique.weight ()) { System.err.println ("Weight change for clique "+clique+" template "+this+" old = "+weight+" new "+clique.weight ()); for (int vi = 0; vi < clique.size(); vi++) { Variable var = clique.get(vi); System.err.println (var+"\t"+var.getNumOutcomes()); } if (weight == -1) { weight = clique.weight (); } else { throw new IllegalStateException ("Error on instance "+instance+": Template "+this+" clique "+clique+" error. Strange weight: was "+weight+" now is "+clique.weight()); } } } } } } private void addInCurrentWeights (BitSet[] weightsPresent)
private void checkCliqueSizeConsistent (InstanceList training) { int weight = -1; for (int i = 0; i < training.size(); i++) { Instance instance = training.get (i); UnrolledGraph unrolled = new UnrolledGraph (instance, new Template[] { this }, null, false); for (Iterator it = unrolled.unrolledVarSetIterator (); it.hasNext();) { UnrolledVarSet clique = (UnrolledVarSet) it.next (); if (clique.tmpl == this) { if (weight != clique.weight ()) { System.err.println ("Weight change for clique "+clique+" template "+this+" old = "+weight+" new "+clique.weight ()); for (int vi = 0; vi < clique.size(); vi++) { Variable var = clique.get(vi); System.err.println (var+"\t"+var.getNumOutcomes()); } if (weight == -1) { weight = clique.weight (); } else { throw new IllegalStateException ("Error on instance "+instance+": Template "+this+" clique "+clique+" error. Strange weight: was "+weight+" now is "+clique.weight()); } } } } } } private void addInCurrentWeights (BitSet[] weightsPresent)
private void checkCliqueSizeConsistent (InstanceList training) { int weight = -1; for (int i = 0; i < training.size(); i++) { Instance instance = training.get (i); UnrolledGraph unrolled = new UnrolledGraph (instance, new Template[] { this }, null, false); for (Iterator it = unrolled.unrolledVarSetIterator (); it.hasNext();) { UnrolledVarSet clique = (UnrolledVarSet) it.next (); if (clique.tmpl == this) { if (weight != clique.weight ()) { System.err.println ("Weight change for clique "+clique+" template "+this+" old = "+weight+" new "+clique.weight ()); for (int vi = 0; vi < clique.size(); vi++) { Variable var = clique.get(vi); System.err.println (var+"\t"+var.getNumOutcomes()); } if (weight == -1) { weight = clique.weight (); } else { throw new IllegalStateException ("Error on instance "+instance+": Template "+this+" clique "+clique+" error. Strange weight: was "+weight+" now is "+clique.weight()); } } } } } } private void addInCurrentWeights (BitSet[] weightsPresent)
public AbstractTableFactor computeFactor (UnrolledVarSet clique) { Matrix phi = createFactorMatrix(clique); SparseVector[] weights = getWeights(); // System.out.println("UnrolledClique "+clique); // System.out.println("FV : "+clique.fv); for (int loc = 0; loc < phi.numLocations(); loc++) { int idx = phi.indexAtLocation(loc); assert idx < weights.length : "Error: Instantiating "+this+" on "+clique+" : Clique has too many " +"assignments.\n # of weights = "+weights.length+" clique weight = "+clique.weight(); SparseVector w = weights[idx]; // System.out.println("Weights "+idx+" : "+w); // w.print(); double dp = w.dotProduct(clique.fv); dp += getDefaultWeight(idx); phi.setValueAtLocation(loc, dp); } AbstractTableFactor ptl = new LogTableFactor(clique); ptl.setValues(phi); return ptl; }
public AbstractTableFactor computeFactor (UnrolledVarSet clique) { Matrix phi = createFactorMatrix(clique); SparseVector[] weights = getWeights(); // System.out.println("UnrolledClique "+clique); // System.out.println("FV : "+clique.fv); for (int loc = 0; loc < phi.numLocations(); loc++) { int idx = phi.indexAtLocation(loc); assert idx < weights.length : "Error: Instantiating "+this+" on "+clique+" : Clique has too many " +"assignments.\n # of weights = "+weights.length+" clique weight = "+clique.weight(); SparseVector w = weights[idx]; // System.out.println("Weights "+idx+" : "+w); // w.print(); double dp = w.dotProduct(clique.fv); dp += getDefaultWeight(idx); phi.setValueAtLocation(loc, dp); } AbstractTableFactor ptl = new LogTableFactor(clique); ptl.setValues(phi); return ptl; }
public AbstractTableFactor computeFactor (UnrolledVarSet clique) { Matrix phi = createFactorMatrix(clique); SparseVector[] weights = getWeights(); // System.out.println("UnrolledClique "+clique); // System.out.println("FV : "+clique.fv); for (int loc = 0; loc < phi.numLocations(); loc++) { int idx = phi.indexAtLocation(loc); assert idx < weights.length : "Error: Instantiating "+this+" on "+clique+" : Clique has too many " +"assignments.\n # of weights = "+weights.length+" clique weight = "+clique.weight(); SparseVector w = weights[idx]; // System.out.println("Weights "+idx+" : "+w); // w.print(); double dp = w.dotProduct(clique.fv); dp += getDefaultWeight(idx); phi.setValueAtLocation(loc, dp); } AbstractTableFactor ptl = new LogTableFactor(clique); ptl.setValues(phi); return ptl; }