Search in sources :

Example 26 with UpdateFunc

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

the class UpdateFuncTest method testSignum.

@Test
public void testSignum() throws Exception {
    UpdateFunc func = new Signum(w2Client.getMatrixId(), 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], Math.signum(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 27 with UpdateFunc

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

the class UpdateFuncTest method testAxpy.

@Test
public void testAxpy() throws Exception {
    w2Client.update(new Fill(w2Client.getMatrixId(), 3, 1.0)).get();
    UpdateFunc func = new Axpy(w2Client.getMatrixId(), 0, 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 + 1, 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 28 with UpdateFunc

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

the class UpdateFuncTest method testMinV.

@Test
public void testMinV() throws Exception {
    UpdateFunc func = new MinV(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], Math.min(localArray1[i], 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 29 with UpdateFunc

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

the class UpdateFuncTest method testRound.

@Test
public void testRound() throws Exception {
    UpdateFunc func = new Round(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.round(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 30 with UpdateFunc

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

the class UpdateFuncTest method testPut.

@Test
public void testPut() throws Exception {
    UpdateFunc func = new Push(w2Client.getMatrixId(), 3, localArray0);
    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], 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)

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