Search in sources :

Example 6 with UpdateFunc

use of com.tencent.angel.ml.matrix.psf.update.enhance.UpdateFunc in project angel by Tencent.

the class UpdateFuncTest method testScale.

@Test
public void testScale() throws Exception {
    w2Client.update(new Push(w2Client.getMatrixId(), 3, localArray0)).get();
    UpdateFunc func = new Scale(w2Client.getMatrixId(), 3, 2.0);
    w2Client.update(func).get();
    double[] result = pull(w2Client, 3);
    assert (result.length == dim);
    for (int i = 0; i < result.length; i++) {
        Assert.assertEquals(result[i], localArray0[i] * 2.0, delta);
    }
}
Also used : CompressUpdateFunc(com.tencent.angel.ml.matrix.psf.update.enhance.CompressUpdateFunc) UpdateFunc(com.tencent.angel.ml.matrix.psf.update.enhance.UpdateFunc) Push(com.tencent.angel.ml.matrix.psf.update.Push) Test(org.junit.Test)

Example 7 with UpdateFunc

use of com.tencent.angel.ml.matrix.psf.update.enhance.UpdateFunc in project angel by Tencent.

the class UpdateFuncTest method testLog10.

@Test
public void testLog10() throws Exception {
    UpdateFunc func = new Log10(w2Client.getMatrixId(), 0, 3);
    w2Client.update(func).get();
    double[] result = pull(w2Client, 3);
    assert (result.length == dim);
    for (int i = 0; i < result.length; i++) {
        Assert.assertEquals(result[i], Math.log10(localArray0[i]), delta);
    }
}
Also used : CompressUpdateFunc(com.tencent.angel.ml.matrix.psf.update.enhance.CompressUpdateFunc) UpdateFunc(com.tencent.angel.ml.matrix.psf.update.enhance.UpdateFunc) Test(org.junit.Test)

Example 8 with UpdateFunc

use of com.tencent.angel.ml.matrix.psf.update.enhance.UpdateFunc in project angel by Tencent.

the class UpdateFuncTest method testSub.

@Test
public void testSub() throws Exception {
    UpdateFunc func = new Sub(w2Client.getMatrixId(), 0, 1, 3);
    w2Client.update(func).get();
    double[] result = pull(w2Client, 3);
    assert (result.length == dim);
    for (int i = 0; i < result.length; i++) {
        Assert.assertEquals(result[i], localArray0[i] - localArray1[i], delta);
    }
}
Also used : CompressUpdateFunc(com.tencent.angel.ml.matrix.psf.update.enhance.CompressUpdateFunc) UpdateFunc(com.tencent.angel.ml.matrix.psf.update.enhance.UpdateFunc) Test(org.junit.Test)

Example 9 with UpdateFunc

use of com.tencent.angel.ml.matrix.psf.update.enhance.UpdateFunc in project angel by Tencent.

the class UpdateFuncTest method testMinA.

@Test
public void testMinA() throws Exception {
    w2Client.update(new Fill(w2Client.getMatrixId(), 3, 0.0)).get();
    UpdateFunc func = new MinA(w2Client.getMatrixId(), 3, localArray1);
    w2Client.update(func).get();
    double[] result = pull(w2Client, 3);
    assert (result.length == dim);
    for (int i = 0; i < result.length; i++) {
        Assert.assertEquals(result[i], Math.min(localArray1[i], 0.0), delta);
    }
}
Also used : CompressUpdateFunc(com.tencent.angel.ml.matrix.psf.update.enhance.CompressUpdateFunc) UpdateFunc(com.tencent.angel.ml.matrix.psf.update.enhance.UpdateFunc) Test(org.junit.Test)

Example 10 with UpdateFunc

use of com.tencent.angel.ml.matrix.psf.update.enhance.UpdateFunc in project angel by Tencent.

the class UpdateFuncTest method testAdd.

@Test
public void testAdd() throws InvalidParameterException, InterruptedException, ExecutionException {
    UpdateFunc func = new Add(w2Client.getMatrixId(), 0, 1, 3);
    w2Client.update(func).get();
    double[] addResult = pull(w2Client, 3);
    assert (addResult.length == dim);
    for (int i = 0; i < addResult.length; i++) {
        Assert.assertEquals(addResult[i], localArray0[i] + localArray1[i], delta);
    }
}
Also used : CompressUpdateFunc(com.tencent.angel.ml.matrix.psf.update.enhance.CompressUpdateFunc) UpdateFunc(com.tencent.angel.ml.matrix.psf.update.enhance.UpdateFunc) Test(org.junit.Test)

Aggregations

UpdateFunc (com.tencent.angel.ml.matrix.psf.update.enhance.UpdateFunc)32 CompressUpdateFunc (com.tencent.angel.ml.matrix.psf.update.enhance.CompressUpdateFunc)31 Test (org.junit.Test)31 Push (com.tencent.angel.ml.matrix.psf.update.Push)2 PartitionKey (com.tencent.angel.PartitionKey)1 PartitionLocation (com.tencent.angel.ml.matrix.PartitionLocation)1 Increment (com.tencent.angel.ml.matrix.psf.update.Increment)1 ByteBuf (io.netty.buffer.ByteBuf)1