private void recomputeFactors () { lastResids = new double [factors ().size ()]; for (Iterator it = cliques.iterator(); it.hasNext();) { UnrolledVarSet clique = (UnrolledVarSet) it.next(); AbstractTableFactor oldF = (AbstractTableFactor) clique.getFactor (); AbstractTableFactor newF = clique.tmpl.computeFactor (clique); double dist = Factors.distLinf ((AbstractTableFactor) oldF.duplicate ().normalize (), (AbstractTableFactor) newF.duplicate ().normalize ()); lastResids [getIndex (oldF)] = dist; oldF.setValues (newF.getLogValueMatrix ()); clique.tmpl.modifyPotential (this, clique, oldF); } }
private void recomputeFactors () { lastResids = new double [factors ().size ()]; for (Iterator it = cliques.iterator(); it.hasNext();) { UnrolledVarSet clique = (UnrolledVarSet) it.next(); AbstractTableFactor oldF = (AbstractTableFactor) clique.getFactor (); AbstractTableFactor newF = clique.tmpl.computeFactor (clique); double dist = Factors.distLinf ((AbstractTableFactor) oldF.duplicate ().normalize (), (AbstractTableFactor) newF.duplicate ().normalize ()); lastResids [getIndex (oldF)] = dist; oldF.setValues (newF.getLogValueMatrix ()); clique.tmpl.modifyPotential (this, clique, oldF); } }
private void recomputeFactors () { lastResids = new double [factors ().size ()]; for (Iterator it = cliques.iterator(); it.hasNext();) { UnrolledVarSet clique = (UnrolledVarSet) it.next(); AbstractTableFactor oldF = (AbstractTableFactor) clique.getFactor (); AbstractTableFactor newF = clique.tmpl.computeFactor (clique); double dist = Factors.distLinf ((AbstractTableFactor) oldF.duplicate ().normalize (), (AbstractTableFactor) newF.duplicate ().normalize ()); lastResids [getIndex (oldF)] = dist; oldF.setValues (newF.getLogValueMatrix ()); clique.tmpl.modifyPotential (this, clique, oldF); } }
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; }