use of com.tencent.angel.ml.matrix.psf.get.indexed.LongIndexGet in project angel by Tencent.
the class IndexGetRowTest method testSparseFloatLongKeyUDF.
public void testSparseFloatLongKeyUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_FLOAT_LONG_MAT, 0);
int matrixW1Id = client1.getMatrixId();
long[] index = genLongIndexs(feaNum, nnz);
LongFloatVector deltaVec = new LongFloatVector(feaNum, new LongFloatSparseVectorStorage(feaNum, nnz));
for (int i = 0; i < nnz; i++) deltaVec.set(index[i], index[i]);
deltaVec.setRowId(0);
client1.increment(deltaVec);
client1.clock().get();
LongIndexGet func = new LongIndexGet(new LongIndexGetParam(matrixW1Id, 0, index));
LongFloatVector row = (LongFloatVector) client1.get(0, index);
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());
}
use of com.tencent.angel.ml.matrix.psf.get.indexed.LongIndexGet in project angel by Tencent.
the class IndexGetRowTest 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);
LongDoubleVector deltaVec = new LongDoubleVector(feaNum, new LongDoubleSparseVectorStorage(feaNum, nnz));
for (int i = 0; i < feaNum; i++) deltaVec.set(i, i);
deltaVec.setRowId(0);
client1.increment(deltaVec);
LongIndexGet func = new LongIndexGet(new LongIndexGetParam(matrixW1Id, 0, index));
LongDoubleVector row = (LongDoubleVector) client1.get(0, index);
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());
}
use of com.tencent.angel.ml.matrix.psf.get.indexed.LongIndexGet in project angel by Tencent.
the class IndexGetRowHashTest method testSparseIntLongKeyUDF.
public void testSparseIntLongKeyUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_INT_LONG_MAT, 0);
int matrixW1Id = client1.getMatrixId();
long[] index = genLongIndexs(feaNum, nnz);
LongIntVector deltaVec = new LongIntVector(feaNum, new LongIntSparseVectorStorage(feaNum, nnz));
for (int i = 0; i < nnz; i++) deltaVec.set(index[i], (int) index[i]);
deltaVec.setRowId(0);
client1.increment(deltaVec);
client1.clock().get();
LongIndexGet func = new LongIndexGet(new LongIndexGetParam(matrixW1Id, 0, index));
LongIntVector row = (LongIntVector) client1.get(0, index);
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());
}
use of com.tencent.angel.ml.matrix.psf.get.indexed.LongIndexGet in project angel by Tencent.
the class IndexGetRowHashTest method testSparseFloatLongKeyUDF.
public void testSparseFloatLongKeyUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_FLOAT_LONG_MAT, 0);
int matrixW1Id = client1.getMatrixId();
long[] index = genLongIndexs(feaNum, nnz);
LongFloatVector deltaVec = new LongFloatVector(feaNum, new LongFloatSparseVectorStorage(feaNum, nnz));
for (int i = 0; i < nnz; i++) deltaVec.set(index[i], index[i]);
deltaVec.setRowId(0);
client1.increment(deltaVec);
client1.clock().get();
LongIndexGet func = new LongIndexGet(new LongIndexGetParam(matrixW1Id, 0, index));
LongFloatVector row = (LongFloatVector) client1.get(0, index);
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());
}
use of com.tencent.angel.ml.matrix.psf.get.indexed.LongIndexGet in project angel by Tencent.
the class IndexGetRowHashTest method testSparseLongLongKeyUDF.
public void testSparseLongLongKeyUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_LONG_LONG_MAT, 0);
int matrixW1Id = client1.getMatrixId();
long[] index = genLongIndexs(feaNum, nnz);
LongLongVector deltaVec = new LongLongVector(feaNum, new LongLongSparseVectorStorage(feaNum, nnz));
for (int i = 0; i < nnz; i++) deltaVec.set(index[i], index[i]);
deltaVec.setRowId(0);
client1.increment(deltaVec);
client1.clock().get();
LongIndexGet func = new LongIndexGet(new LongIndexGetParam(matrixW1Id, 0, index));
LongLongVector row = (LongLongVector) client1.get(0, index);
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());
}
Aggregations