Search in sources :

Example 1 with MatrixClient

use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.

the class IndexGetFuncTest method testSparseDoubleLongKeyUDF.

public void testSparseDoubleLongKeyUDF() throws Exception {
    Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
    MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_DOUBLE_LONG_MAT, 0);
    int matrixW1Id = client1.getMatrixId();
    long[] index = genLongIndexs(feaNum, nnz);
    SparseLongKeyDoubleVector deltaVec = new SparseLongKeyDoubleVector(feaNum);
    for (int i = 0; i < feaNum; i++) deltaVec.set(i, i);
    deltaVec.setRowId(0);
    client1.increment(deltaVec);
    client1.clock().get();
    LongIndexGetFunc func = new LongIndexGetFunc(new LongIndexGetParam(matrixW1Id, 0, index));
    SparseLongKeyDoubleVector row = (SparseLongKeyDoubleVector) ((GetRowResult) client1.get(func)).getRow();
    for (long id : index) {
        System.out.println("id=" + id + ", value=" + row.get(id));
        Assert.assertTrue(row.get(id) == deltaVec.get(id));
    }
// Assert.assertTrue(index.length == row.size());
}
Also used : Worker(com.tencent.angel.worker.Worker) MatrixClient(com.tencent.angel.psagent.matrix.MatrixClient)

Example 2 with MatrixClient

use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.

the class IndexGetFuncTest method testSparseDoubleCompUDF.

public void testSparseDoubleCompUDF() throws Exception {
    Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
    MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_DOUBLE_MAT_COMP, 0);
    int matrixW1Id = client1.getMatrixId();
    int[] index = genIndexs(feaNum, nnz);
    CompSparseDoubleVector deltaVec = new CompSparseDoubleVector(matrixW1Id, 0, feaNum, feaNum);
    for (int i = 0; i < feaNum; i++) deltaVec.set(i, i);
    deltaVec.setRowId(0);
    client1.increment(deltaVec);
    client1.clock().get();
    IndexGetFunc func = new IndexGetFunc(new IndexGetParam(matrixW1Id, 0, index));
    CompSparseDoubleVector row = (CompSparseDoubleVector) ((GetRowResult) client1.get(func)).getRow();
    for (int id : index) {
        System.out.println("id=" + id + ", value=" + row.get(id));
        Assert.assertTrue(row.get(id) == deltaVec.get(id));
    }
    Assert.assertTrue(index.length == row.size());
}
Also used : Worker(com.tencent.angel.worker.Worker) MatrixClient(com.tencent.angel.psagent.matrix.MatrixClient)

Example 3 with MatrixClient

use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.

the class IndexGetFuncTest method testSparseDoubleUDF.

public void testSparseDoubleUDF() throws Exception {
    Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
    MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_DOUBLE_MAT, 0);
    int matrixW1Id = client1.getMatrixId();
    int[] index = genIndexs(feaNum, nnz);
    SparseDoubleVector deltaVec = new SparseDoubleVector(feaNum);
    for (int i = 0; i < feaNum; i++) deltaVec.set(i, i);
    deltaVec.setRowId(0);
    client1.increment(deltaVec);
    client1.clock().get();
    IndexGetFunc func = new IndexGetFunc(new IndexGetParam(matrixW1Id, 0, index));
    SparseDoubleVector row = (SparseDoubleVector) ((GetRowResult) client1.get(func)).getRow();
    for (int id : index) {
        System.out.println("id=" + id + ", value=" + row.get(id));
        Assert.assertTrue(row.get(id) == deltaVec.get(id));
    }
    Assert.assertTrue(index.length == row.size());
}
Also used : Worker(com.tencent.angel.worker.Worker) MatrixClient(com.tencent.angel.psagent.matrix.MatrixClient)

Example 4 with MatrixClient

use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.

the class IndexGetFuncTest method testSparseFloatCompUDF.

public void testSparseFloatCompUDF() throws Exception {
    Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
    MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_FLOAT_MAT_COMP, 0);
    int matrixW1Id = client1.getMatrixId();
    int[] index = genIndexs(feaNum, nnz);
    CompSparseFloatVector deltaVec = new CompSparseFloatVector(matrixW1Id, 0, feaNum, feaNum);
    for (int i = 0; i < feaNum; i++) deltaVec.set(i, i);
    deltaVec.setRowId(0);
    client1.increment(deltaVec);
    client1.clock().get();
    IndexGetFunc func = new IndexGetFunc(new IndexGetParam(matrixW1Id, 0, index));
    CompSparseFloatVector row = (CompSparseFloatVector) ((GetRowResult) client1.get(func)).getRow();
    for (int id : index) {
        System.out.println("id=" + id + ", value=" + row.get(id));
        Assert.assertTrue(row.get(id) == deltaVec.get(id));
    }
    Assert.assertTrue(index.length == row.size());
}
Also used : Worker(com.tencent.angel.worker.Worker) MatrixClient(com.tencent.angel.psagent.matrix.MatrixClient)

Example 5 with MatrixClient

use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.

the class IndexGetFuncTest method testSparseDoubleLongKeyCompUDF.

public void testSparseDoubleLongKeyCompUDF() throws Exception {
    Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
    MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_DOUBLE_LONG_MAT_COMP, 0);
    int matrixW1Id = client1.getMatrixId();
    long[] index = genLongIndexs(feaNum, nnz);
    CompSparseLongKeyDoubleVector deltaVec = new CompSparseLongKeyDoubleVector(matrixW1Id, 0, feaNum, feaNum);
    for (long i = 0; i < feaNum; i++) deltaVec.set(i, i);
    deltaVec.setRowId(0);
    client1.increment(deltaVec);
    client1.clock().get();
    LongIndexGetFunc func = new LongIndexGetFunc(new LongIndexGetParam(matrixW1Id, 0, index));
    CompSparseLongKeyDoubleVector row = (CompSparseLongKeyDoubleVector) ((GetRowResult) client1.get(func)).getRow();
    for (long id : index) {
        System.out.println("id=" + id + ", value=" + row.get(id));
        Assert.assertTrue(row.get(id) == deltaVec.get(id));
    }
// Assert.assertTrue(index.length == row.size());
}
Also used : Worker(com.tencent.angel.worker.Worker) MatrixClient(com.tencent.angel.psagent.matrix.MatrixClient)

Aggregations

MatrixClient (com.tencent.angel.psagent.matrix.MatrixClient)26 Worker (com.tencent.angel.worker.Worker)16 Test (org.junit.Test)10 AngelException (com.tencent.angel.exception.AngelException)7 TVector (com.tencent.angel.ml.math.TVector)6 DenseDoubleVector (com.tencent.angel.ml.math.vector.DenseDoubleVector)6 DenseIntVector (com.tencent.angel.ml.math.vector.DenseIntVector)6 MasterServiceTest (com.tencent.angel.master.MasterServiceTest)5 IOException (java.io.IOException)5 Random (java.util.Random)5 ParameterServer (com.tencent.angel.ps.impl.ParameterServer)4 SparseDoubleVector (com.tencent.angel.ml.math.vector.SparseDoubleVector)3 PSAttemptId (com.tencent.angel.ps.PSAttemptId)3 MatrixStorageManager (com.tencent.angel.ps.impl.MatrixStorageManager)3 ServerMatrix (com.tencent.angel.ps.impl.matrix.ServerMatrix)3 IndexGetFunc (com.tencent.angel.ml.matrix.psf.get.enhance.indexed.IndexGetFunc)2 IndexGetParam (com.tencent.angel.ml.matrix.psf.get.enhance.indexed.IndexGetParam)2 ParameterServerId (com.tencent.angel.ps.ParameterServerId)2 ServerDenseIntRow (com.tencent.angel.ps.impl.matrix.ServerDenseIntRow)2 GetRowsResult (com.tencent.angel.psagent.matrix.transport.adapter.GetRowsResult)2