use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.
the class GetRowHashTest method testSparseFloatUDF.
public void testSparseFloatUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_FLOAT_MAT, 0);
int[] index = genIndexs(feaNum, nnz);
IntFloatVector deltaVec = new IntFloatVector(feaNum, new IntFloatSparseVectorStorage(feaNum, nnz));
for (int i = 0; i < index.length; i++) {
deltaVec.set(index[i], index[i]);
}
deltaVec.setRowId(0);
client1.increment(deltaVec);
IntFloatVector row = (IntFloatVector) client1.getRow(0);
for (int id : index) {
assertEquals(row.get(id), deltaVec.get(id), 0.000001);
}
Assert.assertTrue(index.length == row.size());
}
use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.
the class GetRowHashTest method testSparseDoubleUDF.
public void testSparseDoubleUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_DOUBLE_MAT, 0);
int[] index = genIndexs(feaNum, nnz);
IntDoubleVector deltaVec = new IntDoubleVector(feaNum, new IntDoubleSparseVectorStorage(feaNum, nnz));
for (int i = 0; i < index.length; i++) {
deltaVec.set(index[i], index[i]);
}
deltaVec.setRowId(0);
client1.increment(deltaVec);
IntDoubleVector row = (IntDoubleVector) client1.getRow(0, true);
for (int id : index) {
Assert.assertTrue(row.get(id) == deltaVec.get(id));
}
Assert.assertTrue(index.length == row.size());
}
use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.
the class GetRowsHashTest 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 = null;
for (int rowId = 0; rowId < rowNum; rowId++) {
deltaVec = new LongFloatVector(feaNum, new LongFloatSparseVectorStorage(feaNum));
for (int i = 0; i < index.length; i++) {
deltaVec.set(index[i], index[i]);
}
client1.increment(rowId, deltaVec, true);
}
int[] rowIds = new int[rowNum];
for (int i = 0; i < rowNum; i++) {
rowIds[i] = i;
}
Vector[] rows = client1.getRows(rowIds);
for (int i = 0; i < rowNum; i++) {
for (long id : index) {
Assert.assertEquals(((LongFloatVector) rows[i]).get(id), deltaVec.get(id), zero);
}
}
}
use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.
the class IncrementRowHashTest method testDenseFloatUDF.
public void testDenseFloatUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(DENSE_FLOAT_MAT, 0);
int[] index = genIndexs(feaNum, nnz);
IntFloatVector deltaVec = new IntFloatVector(feaNum, new IntFloatDenseVectorStorage(feaNum));
for (int i = 0; i < feaNum; i++) deltaVec.set(i, i);
deltaVec.setRowId(0);
client1.increment(deltaVec, true);
IntFloatVector row = (IntFloatVector) client1.getRow(0);
for (int id : index) {
Assert.assertTrue(row.get(id) == deltaVec.get(id));
}
Assert.assertTrue(feaNum == row.size());
}
use of com.tencent.angel.psagent.matrix.MatrixClient in project angel by Tencent.
the class IncrementRowHashTest method testSparseLongLongKeyUDF.
public void testSparseLongLongKeyUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_LONG_LONG_MAT, 0);
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, true);
LongLongVector row = (LongLongVector) client1.getRow(0);
for (long id : index) {
// System.out.println("id=" + id + ", value=" + row.get(id));
Assert.assertEquals(row.get(id), deltaVec.get(id));
}
// Assert.assertTrue(index.length == row.size());
}
Aggregations