use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.
the class Min method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
PartIncrementRowsParam param = (PartIncrementRowsParam) partParam;
List<RowUpdateSplit> updates = param.getUpdates();
for (RowUpdateSplit update : updates) {
ServerRow row = psContext.getMatrixStorageManager().getRow(param.getPartKey(), update.getRowId());
row.startWrite();
try {
Vector vector = getVector(param.getMatrixId(), update.getRowId(), param.getPartKey());
Ufuncs.imin(vector, update.getVector());
} finally {
row.endWrite();
}
}
}
use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.
the class Max method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
PartIncrementRowsParam param = (PartIncrementRowsParam) partParam;
List<RowUpdateSplit> updates = param.getUpdates();
for (RowUpdateSplit update : updates) {
ServerRow row = psContext.getMatrixStorageManager().getRow(param.getPartKey(), update.getRowId());
row.startWrite();
try {
Vector vector = getVector(param.getMatrixId(), update.getRowId(), param.getPartKey());
Ufuncs.imax(vector, update.getVector());
} finally {
row.endWrite();
}
}
}
use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.
the class Sub method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
PartIncrementRowsParam param = (PartIncrementRowsParam) partParam;
List<RowUpdateSplit> updates = param.getUpdates();
for (RowUpdateSplit update : updates) {
ServerRow row = psContext.getMatrixStorageManager().getRow(param.getPartKey(), update.getRowId());
row.startWrite();
try {
Vector vector = getVector(param.getMatrixId(), update.getRowId(), param.getPartKey());
vector.isub(update.getVector());
} finally {
row.endWrite();
}
}
}
use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.
the class PartCSRResult method bufferLen.
@Override
public int bufferLen() {
int len = 4;
for (ServerRow row : splits) {
if (row.isDense()) {
int[] values = ServerRowUtils.getVector((ServerIntIntRow) row).getStorage().getValues();
int size = (int) (row.getEndCol() - row.getStartCol());
int cnt = 0;
for (int i = 0; i < size; i++) if (values[i] > 0)
cnt++;
len += 1 + 4;
if (cnt > size * 0.5) {
// dense
len += 4 * size;
} else {
// sparse
len += 8 * cnt;
}
} else if (row.isSparse()) {
int[] values = ServerRowUtils.getVector((ServerIntIntRow) row).getStorage().getValues();
int size = values.length;
int cnt = 0;
for (int i = 0; i < size; i++) if (values[i] > 0)
cnt++;
len += 1 + 4 + 8 * cnt;
} else
return len;
}
return len;
}
use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.
the class AdaGradUpdateFunc method update.
@Override
public void update(RowBasedPartition partition, int factor, double[] scalars) {
double epsilon = scalars[0];
double beta = scalars[1];
double lr = scalars[2];
double l1RegParam = scalars[3];
double l2RegParam = scalars[4];
double epoch = (int) scalars[5];
double batchSize = (int) scalars[6];
for (int f = 0; f < factor; f++) {
ServerRow gradientServerRow = partition.getRow(f + 2 * factor);
try {
gradientServerRow.startWrite();
Vector weight = ServerRowUtils.getVector(partition.getRow(f));
Vector square = ServerRowUtils.getVector(partition.getRow(f + factor));
Vector gradient = ServerRowUtils.getVector(gradientServerRow);
if (batchSize > 1) {
gradient.idiv(batchSize);
}
OptFuncs.iexpsmoothing2(square, gradient, beta);
if (l2RegParam != 0) {
gradient.iaxpy(weight, l2RegParam);
}
OptFuncs.iadagraddelta(gradient, square, l2RegParam, lr);
weight.isub(gradient);
if (l1RegParam != 0) {
OptFuncs.iadagradthredshold(weight, square, l1RegParam, l2RegParam, lr);
}
gradient.clear();
} finally {
gradientServerRow.endWrite();
}
}
}
Aggregations