use of com.tencent.angel.ml.matrix.psf.update.enhance.MultiRowUpdateParam.MultiRowPartitionUpdateParam in project angel by Tencent.
the class ComputeW method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
if (partParam instanceof MultiRowPartitionUpdateParam) {
MultiRowPartitionUpdateParam param = (MultiRowPartitionUpdateParam) partParam;
int[] rowIds = param.getRowIds();
double[][] values = param.getValues();
double alpha = values[0][0];
double beta = values[0][1];
double lambda1 = values[0][2];
double lambda2 = values[0][3];
int offset = (int) values[1][0];
RowBasedPartition part = (RowBasedPartition) psContext.getMatrixStorageManager().getPart(param.getPartKey());
for (int i = 0; i < offset; i++) {
Vector z = ServerRowUtils.getVector(part.getRow(rowIds[0] * offset + i));
Vector n = ServerRowUtils.getVector(part.getRow(rowIds[1] * offset + i));
Vector w = Ufuncs.ftrlthreshold(z, n, alpha, beta, lambda1, lambda2);
ServerRowUtils.setVector(part.getRow(rowIds[2] * offset + i), w.ifilter(1e-11));
}
// // calculate bias
// if (param.getPartKey().getStartCol() <= 0 && param.getPartKey().getEndCol() > 0) {
// double zVal = VectorUtils.getDouble(z, 0);
// double nVal = VectorUtils.getDouble(n, 0);
// VectorUtils.setFloat(w, 0, (float) (-1.0 * alpha * zVal / (beta + Math.sqrt(nVal))));
// }
}
}
Aggregations