Search in sources :

Example 1 with SquareL2Loss

use of com.tencent.angel.ml.optimizer.sgd.loss.SquareL2Loss in project angel by Tencent.

the class SquareLossTest method testLoss.

@Test
public void testLoss() throws Exception {
    double dot = 1.0, y = 2.0;
    SquareL2Loss squareLoss = new SquareL2Loss();
    double test = squareLoss.loss(dot, y);
    assertEquals(0.50, test, 0.00);
}
Also used : SquareL2Loss(com.tencent.angel.ml.optimizer.sgd.loss.SquareL2Loss) Test(org.junit.Test)

Example 2 with SquareL2Loss

use of com.tencent.angel.ml.optimizer.sgd.loss.SquareL2Loss in project angel by Tencent.

the class SquareLossTest method testGrad.

@Test
public void testGrad() throws Exception {
    double dot = 1.0, y = 2.0;
    SquareL2Loss squareLoss = new SquareL2Loss();
    double test = squareLoss.grad(dot, y);
    assertEquals(1.0, test, 0.00);
}
Also used : SquareL2Loss(com.tencent.angel.ml.optimizer.sgd.loss.SquareL2Loss) Test(org.junit.Test)

Example 3 with SquareL2Loss

use of com.tencent.angel.ml.optimizer.sgd.loss.SquareL2Loss in project angel by Tencent.

the class SquareLossTest method testPredict.

@Test
public void testPredict() throws Exception {
    double[] data1 = { 1.0, 2.0, 3.0, 4.0 };
    DenseDoubleVector denseDoubleVector1 = new DenseDoubleVector(4, data1);
    double[] data2 = { 1.0, 2.0, 3.0, 4.0 };
    DenseDoubleVector denseDoubleVector2 = new DenseDoubleVector(4, data2);
    SquareL2Loss squareLoss = new SquareL2Loss();
    double test = squareLoss.predict(denseDoubleVector1, denseDoubleVector2);
    double dot = 0.0;
    for (int i = 0; i < data1.length; i++) dot += data1[i] * data2[i];
    assertEquals(dot, test, 0.00);
}
Also used : DenseDoubleVector(com.tencent.angel.ml.math.vector.DenseDoubleVector) SquareL2Loss(com.tencent.angel.ml.optimizer.sgd.loss.SquareL2Loss) Test(org.junit.Test)

Aggregations

SquareL2Loss (com.tencent.angel.ml.optimizer.sgd.loss.SquareL2Loss)3 Test (org.junit.Test)3 DenseDoubleVector (com.tencent.angel.ml.math.vector.DenseDoubleVector)1