public void printMatrixStats(PrintStream out) { log.info("Model loaded with " + numUnaryMatrices + " unary and " + numBinaryMatrices + " binary"); for (TwoDimensionalMap.Entry<String, String, SimpleMatrix> binary : binaryTransform) { out.println("Binary transform " + binary.getFirstKey() + ":" + binary.getSecondKey()); double normf = binary.getValue().normF(); out.println(" Total norm " + (normf * normf)); normf = binary.getValue().extractMatrix(0, op.lexOptions.numHid, 0, op.lexOptions.numHid).normF(); out.println(" Left norm (" + binary.getFirstKey() + ") " + (normf * normf)); normf = binary.getValue().extractMatrix(0, op.lexOptions.numHid, op.lexOptions.numHid, op.lexOptions.numHid*2).normF(); out.println(" Right norm (" + binary.getSecondKey() + ") " + (normf * normf)); } }
SimpleMatrix gappedEmbedding = gappedArguments.get(j - 1).getAverageEmbeddings(); distance = fullEmbedding.minus(gappedEmbedding).normF();
double normF = subtrees.get(i).second().minus(subtrees.get(j).second()).normF();
public void printMatrixStats(PrintStream out) { System.err.println("Model loaded with " + numUnaryMatrices + " unary and " + numBinaryMatrices + " binary"); for (TwoDimensionalMap.Entry<String, String, SimpleMatrix> binary : binaryTransform) { out.println("Binary transform " + binary.getFirstKey() + ":" + binary.getSecondKey()); double normf = binary.getValue().normF(); out.println(" Total norm " + (normf * normf)); normf = binary.getValue().extractMatrix(0, op.lexOptions.numHid, 0, op.lexOptions.numHid).normF(); out.println(" Left norm (" + binary.getFirstKey() + ") " + (normf * normf)); normf = binary.getValue().extractMatrix(0, op.lexOptions.numHid, op.lexOptions.numHid, op.lexOptions.numHid*2).normF(); out.println(" Right norm (" + binary.getSecondKey() + ") " + (normf * normf)); } }
public void printMatrixStats(PrintStream out) { log.info("Model loaded with " + numUnaryMatrices + " unary and " + numBinaryMatrices + " binary"); for (TwoDimensionalMap.Entry<String, String, SimpleMatrix> binary : binaryTransform) { out.println("Binary transform " + binary.getFirstKey() + ":" + binary.getSecondKey()); double normf = binary.getValue().normF(); out.println(" Total norm " + (normf * normf)); normf = binary.getValue().extractMatrix(0, op.lexOptions.numHid, 0, op.lexOptions.numHid).normF(); out.println(" Left norm (" + binary.getFirstKey() + ") " + (normf * normf)); normf = binary.getValue().extractMatrix(0, op.lexOptions.numHid, op.lexOptions.numHid, op.lexOptions.numHid*2).normF(); out.println(" Right norm (" + binary.getSecondKey() + ") " + (normf * normf)); } }
public void printMatrixStats(PrintStream out) { log.info("Model loaded with " + numUnaryMatrices + " unary and " + numBinaryMatrices + " binary"); for (TwoDimensionalMap.Entry<String, String, SimpleMatrix> binary : binaryTransform) { out.println("Binary transform " + binary.getFirstKey() + ":" + binary.getSecondKey()); double normf = binary.getValue().normF(); out.println(" Total norm " + (normf * normf)); normf = binary.getValue().extractMatrix(0, op.lexOptions.numHid, 0, op.lexOptions.numHid).normF(); out.println(" Left norm (" + binary.getFirstKey() + ") " + (normf * normf)); normf = binary.getValue().extractMatrix(0, op.lexOptions.numHid, op.lexOptions.numHid, op.lexOptions.numHid*2).normF(); out.println(" Right norm (" + binary.getSecondKey() + ") " + (normf * normf)); } }
/** * <p> * Computes a metric which measures the the quality of an eigen value decomposition. If a * value is returned that is close to or smaller than 1e-15 then it is within machine precision. * </p> * <p> * EVD quality is defined as:<br> * <br> * Quality = ||A*V - V*D|| / ||A*V||. * </p> * * @param orig The original matrix. Not modified. * @param eig EVD of the original matrix. Not modified. * @return The quality of the decomposition. */ public static double quality( DenseMatrix64F orig , EigenDecomposition<DenseMatrix64F> eig ) { SimpleMatrix A = SimpleMatrix.wrap(orig); SimpleMatrix V = SimpleMatrix.wrap(EigenOps.createMatrixV(eig)); SimpleMatrix D = SimpleMatrix.wrap(EigenOps.createMatrixD(eig)); SimpleMatrix L = A.mult(V); SimpleMatrix R = V.mult(D); SimpleMatrix diff = L.minus(R); double top = diff.normF(); double bottom = L.normF(); double error = top/bottom; return error; }
/** * <p> * Computes a metric which measures the the quality of an eigen value decomposition. If a * value is returned that is close to or smaller than 1e-15 then it is within machine precision. * </p> * <p> * EVD quality is defined as:<br> * <br> * Quality = ||A*V - V*D|| / ||A*V||. * </p> * * @param orig The original matrix. Not modified. * @param eig EVD of the original matrix. Not modified. * @return The quality of the decomposition. */ public static double quality( DenseMatrix64F orig , EigenDecomposition<DenseMatrix64F> eig ) { SimpleMatrix A = SimpleMatrix.wrap(orig); SimpleMatrix V = SimpleMatrix.wrap(EigenOps.createMatrixV(eig)); SimpleMatrix D = SimpleMatrix.wrap(EigenOps.createMatrixD(eig)); SimpleMatrix L = A.mult(V); SimpleMatrix R = V.mult(D); SimpleMatrix diff = L.minus(R); double top = diff.normF(); double bottom = L.normF(); double error = top/bottom; return error; }
public static double quality( DenseMatrix64F orig , DenseMatrix64F U , DenseMatrix64F W , DenseMatrix64F Vt ) { SimpleMatrix _U = SimpleMatrix.wrap(U); SimpleMatrix _W = SimpleMatrix.wrap(W); SimpleMatrix _Vt = SimpleMatrix.wrap(Vt); SimpleMatrix foundA = _U.mult(_W).mult(_Vt); return SpecializedOps.diffNormF(orig,foundA.getMatrix())/foundA.normF(); }
public static double quality( DenseMatrix64F orig , DenseMatrix64F U , DenseMatrix64F W , DenseMatrix64F Vt ) { SimpleMatrix _U = SimpleMatrix.wrap(U); SimpleMatrix _W = SimpleMatrix.wrap(W); SimpleMatrix _Vt = SimpleMatrix.wrap(Vt); SimpleMatrix foundA = _U.mult(_W).mult(_Vt); return SpecializedOps.diffNormF(orig,foundA.getMatrix())/foundA.normF(); }
/** * Runs LSPI for either numIterations or until the change in the weight matrix is no greater than maxChange. * @param numIterations the maximum number of policy iterations. * @param maxChange when the weight change is smaller than this value, LSPI terminates. * @return a {@link burlap.behavior.policy.GreedyQPolicy} using this object as the {@link QProvider} source. */ public GreedyQPolicy runPolicyIteration(int numIterations, double maxChange){ boolean converged = false; for(int i = 0; i < numIterations && !converged; i++){ SimpleMatrix nw = this.LSTDQ(); double change = Double.POSITIVE_INFINITY; if(this.lastWeights != null){ change = this.lastWeights.minus(nw).normF(); if(change <= maxChange){ converged = true; } } this.lastWeights = nw; DPrint.cl(0, "Finished iteration: " + i + ". Weight change: " + change); } DPrint.cl(0, "Finished Policy Iteration."); return new GreedyQPolicy(this); }
double correction_mag = refPos.minusXYZ(rover).normF(); double tg = (roverObs.getRefTime().getMsec() - refTime)/1000;
double correction_mag = refPos.minusXYZ(rover).normF(); double tg = (roverObs.getRefTime().getMsec() - refTime)/1000;
cdt = possiblePosA.get(3, 0); calc = B.extractMatrix(i, i+1, 0, 3).transpose().minus( possiblePosA.extractMatrix(0, 3, 0, 1)).normF() + cdt; omc[0] = B.get(i, 3) - calc; cdt = possiblePosB.get(3, 0); calc = B.extractMatrix(i, i+1, 0, 3).transpose().minus( possiblePosB.extractMatrix(0, 3, 0, 1)).normF() + cdt; omc[1] = B.get(i, 3) - calc;