List of usage examples for edu.stanford.nlp.math ArrayMath addMultInto
public static void addMultInto(double[] a, double[] b, double[] c, double d)
From source file:cmu.arktweetnlp.impl.OWLQN.java
private boolean getNextPoint(double alpha) { ArrayMath.addMultInto(newX, x, dir, alpha); /*if (OWLQN.isConstrained()) newX = OWLQN.projectWeights(newX);*/ //TODO if (l1weight > 0) { for (int i = 0; i < dim; i++) { //mheilman: I added this if-statement to avoid penalizing bias parameters. if (OWLQN.biasParameters.contains(i)) { continue; }//from w ww. j a va2s .c o m if (x[i] * newX[i] < 0.0) { newX[i] = 0.0; } } } return true; }
From source file:cmu.arktweetnlp.impl.OWLQN.java
void shift() { double[] nextS = null, nextY = null; int listSize = sList.size(); if (listSize < m) { try {//from w ww. j a v a 2 s . c o m nextS = new double[dim]; nextY = new double[dim]; } catch (OutOfMemoryError e) { m = listSize; nextS = null; } } if (nextS == null) { nextS = sList.poll(); nextY = yList.poll(); roList.poll(); } ArrayMath.addMultInto(nextS, newX, x, -1); ArrayMath.addMultInto(nextY, newGrad, grad, -1); double ro = ArrayMath.innerProduct(nextS, nextY); assert (ro != 0.0); sList.offer(nextS); yList.offer(nextY); roList.offer(ro); double[] tmpX = newX; newX = x; x = tmpX; // TODO: added: nschneid /*if (OWLQN.isConstrained()) { newX = OWLQN.projectWeights(newX); x = OWLQN.projectWeights(x); }*/ double[] tmpGrad = newGrad; newGrad = grad; grad = tmpGrad; ++iter; }
From source file:dz.pfe.storm.ressources.cmu.arktweetnlp.impl.OWLQN.java
private synchronized boolean getNextPoint(double alpha) { OWLQN owlqn = new OWLQN(); ArrayMath.addMultInto(newX, x, dir, alpha); /*if (OWLQN.isConstrained()) newX = OWLQN.projectWeights(newX);*/ //TODO if (l1weight > 0) { for (int i = 0; i < dim; i++) { //mheilman: I added this if-statement to avoid penalizing bias parameters. if (owlqn.biasParameters.contains(i)) { continue; }//from www . j a v a2s .co m if (x[i] * newX[i] < 0.0) { newX[i] = 0.0; } } } return true; }
From source file:dz.pfe.storm.ressources.cmu.arktweetnlp.impl.OWLQN.java
synchronized void shift() { double[] nextS = null, nextY = null; int listSize = sList.size(); if (listSize < m) { try {//from w w w .jav a2 s. c om nextS = new double[dim]; nextY = new double[dim]; } catch (OutOfMemoryError e) { m = listSize; nextS = null; } } if (nextS == null) { nextS = sList.poll(); nextY = yList.poll(); roList.poll(); } ArrayMath.addMultInto(nextS, newX, x, -1); ArrayMath.addMultInto(nextY, newGrad, grad, -1); double ro = ArrayMath.innerProduct(nextS, nextY); assert (ro != 0.0); sList.offer(nextS); yList.offer(nextY); roList.offer(ro); double[] tmpX = newX; newX = x; x = tmpX; // TODO: added: nschneid /*if (OWLQN.isConstrained()) { newX = OWLQN.projectWeights(newX); x = OWLQN.projectWeights(x); }*/ double[] tmpGrad = newGrad; newGrad = grad; grad = tmpGrad; ++iter; }
From source file:impl.features.OWLQN.java
private boolean getNextPoint(double alpha) { ArrayMath.addMultInto(newX, x, dir, alpha); /*if (OWLQN.isConstrained()) newX = OWLQN.projectWeights(newX);*/ //TODO OWLQN.projectWeights if (l1weight > 0) { for (int i = 0; i < dim; i++) { //mheilman: I added this if-statement to avoid penalizing bias parameters. if (OWLQN.biasParameters.contains(i)) { continue; }// w w w . ja va 2s . c om if (x[i] * newX[i] < 0.0) { newX[i] = 0.0; } } } return true; }