Search in sources :

Example 1 with MultiRowPartitionUpdateParam

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))));
    // }
    }
}
Also used : MultiRowPartitionUpdateParam(com.tencent.angel.ml.matrix.psf.update.enhance.MultiRowUpdateParam.MultiRowPartitionUpdateParam) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition) Vector(com.tencent.angel.ml.math2.vector.Vector)

Aggregations

Vector (com.tencent.angel.ml.math2.vector.Vector)1 MultiRowPartitionUpdateParam (com.tencent.angel.ml.matrix.psf.update.enhance.MultiRowUpdateParam.MultiRowPartitionUpdateParam)1 RowBasedPartition (com.tencent.angel.ps.storage.partition.RowBasedPartition)1