Package fr.lip6.jkernelmachines.threading

Examples of fr.lip6.jkernelmachines.threading.ThreadedMatrixOperator


    //rebuild matrix
    kmatrix = kernel.getKernelMatrix(tlist);
   
    //rebuild gradient
    final double[] tmp = new double[g.length];
    (new ThreadedMatrixOperator(){

      @Override
      public void doLines(double[][] matrix, int from, int to) {
        for(int index = from ; index < to ; index++)
        {
View Full Code Here


    debug.println(4, "svmObj : alphas = "+Arrays.toString(alp));
//    debug.println(4, "svmObj : b="+svm.getB());
       
    //parallelized
    final double[] resLine = new double[kmatrix.length];
    ThreadedMatrixOperator objFactory = new ThreadedMatrixOperator()
    {
      @Override
      public void doLines(double[][] matrix, int from , int to) {
        for(int index = from ; index < to ; index++)
        {
          resLine[index] = 0;
          if(abs(alp[index]) > 0)
          {
            double al1 = abs(alp[index]) * l.get(index).label;
            for(int j = 0 ; j < matrix[index].length ; j++)
            {
              if(abs(alp[j]) > 0)
                resLine[index] += al1 * abs(alp[j]) * l.get(j).label * matrix[index][j];
            }
          }
        }
      } 
    };
   
    objFactory.getMatrix(kmatrix);
    double obj1 = 0;
    for(double d : resLine)
      obj1 += d;
   
    double obj2 = 0;
View Full Code Here

      Kernel<T> k = km.get(i);
      double kmatrix[][] = k.getKernelMatrix(l);
           
      //parallelized
      final double[] resLine = new double[kmatrix.length];
      ThreadedMatrixOperator gradFactory = new ThreadedMatrixOperator()
      {
        @Override
        public void doLines(double[][] matrix , int from , int to) {
          for(int index = from ; index < to ; index++)
          {
            resLine[index] = 0;
            if(alp[index] > 0)
            {
              double al1 = -0.5 * alp[index] * l.get(index).label;
              for(int j = 0 ; j < matrix[index].length ; j++)
              {
                resLine[index] += al1 * alp[j] * l.get(j).label * matrix[index][j];
              }
            }
          }
        } 
      };
     
      gradFactory.getMatrix(kmatrix);
      double g = 0;
      for(double d : resLine)
        g += d;
      grad.add(i, g);
    }
View Full Code Here

        continue;
     

      final double[][] m = k.getKernelMatrix(l);
      // specific factory
      ThreadedMatrixOperator tmo = new ThreadedMatrixOperator(){
       
        @Override
        public void doLines(double[][] matrix , int from , int to) {
          for(int index = from ; index < to ; index++)
          {
            for(int j = 0 ; j < matrix[index].length ; j++)
            {
              matrix[index][j] += m[index][j] * w;
            }
          }
        };
       
      };
     
      matrix = tmo.getMatrix(matrix);
    }
   
   
    return matrix;
  }
View Full Code Here

        continue;
     

      final double[][] m = k.getKernelMatrix(l);
      // specific factory
      ThreadedMatrixOperator tmo = new ThreadedMatrixOperator(){
       
        @Override
        public void doLines(double[][] matrix , int from , int to) {
         
          for(int index = from ; index < to ; index++)
          {
            for(int i = 0 ; i < m[index].length ; i++)
            {
              matrix[index][i] *= Math.pow(m[index][i], w);
            }
          }
        };
       
      };
     
      matrix = tmo.getMatrix(matrix);
    }
   
    return matrix;
  }
View Full Code Here

        continue;
     
      k.setGamma(w);
      final double[][] m = k.getKernelMatrix(l);
      // specific factory
      ThreadedMatrixOperator tmo = new ThreadedMatrixOperator(){
       
        @Override
        public void doLines(double[][] matrix , int from , int to) {
         
          for(int index = from ; index < to ; index++)
          {
            for(int i = 0 ; i < m[index].length ; i++)
            {
              matrix[index][i] *= m[index][i];
            }
          }
        };
       
      };
     
      matrix = tmo.getMatrix(matrix);
    }
   
    return matrix;
  }
View Full Code Here

  LaSVM<double[]> svm;

  @Before
  public void setUp() throws Exception {
   
    GaussianGenerator g = new GaussianGenerator(10, 5.0f, 1.0);
    train = g.generateList(10);
   
    DoubleGaussL2 k = new DoubleGaussL2(1.0);
    svm = new LaSVM<double[]>(k);
  }
View Full Code Here

  LaSVM<double[]> svm;

  @Before
  public void setUp() throws Exception {
   
    GaussianGenerator g = new GaussianGenerator(10, 5.0f, 1.0);
    train = g.generateList(10);
   
    DoubleGaussL2 k = new DoubleGaussL2(1.0);
    svm = new LaSVM<double[]>(k);
  }
View Full Code Here

  /**
   * @throws java.lang.Exception
   */
  @Before
  public void setUp() throws Exception {
    g = new GaussianGenerator();
  }
View Full Code Here

  /**
   * Test method for {@link fr.lip6.jkernelmachines.util.generators.GaussianGenerator#GaussianGenerator(int)}.
   */
  @Test
  public final void testGaussianGeneratorInt() {
    g = new GaussianGenerator(2);
    assertEquals(2, g.getDimension());
  }
View Full Code Here

TOP

Related Classes of fr.lip6.jkernelmachines.threading.ThreadedMatrixOperator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.