コード例 #1
0
ファイル: OWLQNState.java プロジェクト: rikima/myowlqn
  /**
   * shift
   *
   * <p>store the s and y vectors.
   */
  private void shift() {
    double[] nextS = null;
    double[] nextY = null;

    int listSize = sList.size();

    if (listSize < m) {
      nextS = new double[dim + 1];
      nextY = new double[dim + 1];
    }

    if (nextS == null) {
      nextS = sList.firstElement();
      sList.remove(0);

      nextY = yList.firstElement();
      yList.remove(0);
      roList.remove(0);
    }

    addMultInto(nextS, newW, w, -1);
    addMultInto(nextY, newGrad, grad, -1);

    double ro = ArrayUtils.dot(nextS, nextY);

    sList.add(nextS);
    yList.add(nextY);
    roList.add(ro);

    ArrayUtils.copy(newW, w);
    ArrayUtils.copy(newGrad, grad);
    iter++;
  }
コード例 #2
0
 public synchronized void loadShader(ShaderContainer scont, String vertex, String frag) {
   ShaderLoadJob sljob = new ShaderLoadJob(vertex, frag);
   ShaderProgramm sprog = (ShaderProgramm) ressourcen.get(sljob);
   if (sprog == null) {
     List<ShaderContainer> l = scontainer.get(sljob);
     if (l == null) {
       l = new LinkedList<ShaderContainer>();
       scontainer.put(sljob, l);
       sljob.setConList(l);
       jobs.add(sljob);
     }
     l.add(scont);
   } else {
     scontainer.get(sljob).add(scont);
     shadertoset.add(new ThreadSafeShaderLoading(scont, sprog));
   }
 }
コード例 #3
0
ファイル: OWLQNState.java プロジェクト: rikima/myowlqn
  /**
   * get value
   *
   * @return
   */
  private double getValue() {

    double retVal = Double.MAX_VALUE;

    if (prevVals.size() > m / 2) {

      double prevVal = prevVals.firstElement();
      if (prevVals.size() == m) {
        prevVals.remove(0);
      }

      double averageImprovement = (prevVal - this.value) / prevVals.size();
      double relAvgImpr = averageImprovement / Math.abs(this.value);

      retVal = relAvgImpr;
    } else {
      if (DEBUG || verbose) {
        stderr.println("  (wait for five iters) ");
      }
    }

    prevVals.add(this.value);
    return retVal;
  }