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);
}
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);
}
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);
}
Aggregations