Package ml.shifu.guagua.example.lr
Class LogisticRegressionWorker
- java.lang.Object
-
- ml.shifu.guagua.worker.AbstractWorkerComputable<LogisticRegressionParams,LogisticRegressionParams,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.Text>>
-
- ml.shifu.guagua.example.lr.LogisticRegressionWorker
-
- All Implemented Interfaces:
ml.shifu.guagua.worker.WorkerComputable<LogisticRegressionParams,LogisticRegressionParams>
public class LogisticRegressionWorker extends ml.shifu.guagua.worker.AbstractWorkerComputable<LogisticRegressionParams,LogisticRegressionParams,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.Text>>
LogisticRegressionWorkerdefines logic to accumulate local logistic regression gradients.At first iteration, wait for master to use the consistent initiated model.
At other iterations, workers include:
- 1. Update local model by using global model from last step..
- 2. Accumulate gradients by using local worker input data.
- 3. Send new local gradients to master by returning parameters.
-
-
Constructor Summary
Constructors Constructor Description LogisticRegressionWorker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LogisticRegressionParamsdoCompute(ml.shifu.guagua.worker.WorkerContext<LogisticRegressionParams,LogisticRegressionParams> context)voidinit(ml.shifu.guagua.worker.WorkerContext<LogisticRegressionParams,LogisticRegressionParams> context)voidinitRecordReader(ml.shifu.guagua.io.GuaguaFileSplit fileSplit)voidload(ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable> currentKey, ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.Text> currentValue, ml.shifu.guagua.worker.WorkerContext<LogisticRegressionParams,LogisticRegressionParams> context)protected voidpostLoad(ml.shifu.guagua.worker.WorkerContext<LogisticRegressionParams,LogisticRegressionParams> context)
-
-
-
Method Detail
-
initRecordReader
public void initRecordReader(ml.shifu.guagua.io.GuaguaFileSplit fileSplit) throws IOException- Specified by:
initRecordReaderin classml.shifu.guagua.worker.AbstractWorkerComputable<LogisticRegressionParams,LogisticRegressionParams,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.Text>>- Throws:
IOException
-
init
public void init(ml.shifu.guagua.worker.WorkerContext<LogisticRegressionParams,LogisticRegressionParams> context)
- Specified by:
initin classml.shifu.guagua.worker.AbstractWorkerComputable<LogisticRegressionParams,LogisticRegressionParams,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.Text>>
-
doCompute
public LogisticRegressionParams doCompute(ml.shifu.guagua.worker.WorkerContext<LogisticRegressionParams,LogisticRegressionParams> context)
- Specified by:
doComputein classml.shifu.guagua.worker.AbstractWorkerComputable<LogisticRegressionParams,LogisticRegressionParams,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.Text>>
-
postLoad
protected void postLoad(ml.shifu.guagua.worker.WorkerContext<LogisticRegressionParams,LogisticRegressionParams> context)
- Overrides:
postLoadin classml.shifu.guagua.worker.AbstractWorkerComputable<LogisticRegressionParams,LogisticRegressionParams,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.Text>>
-
load
public void load(ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable> currentKey, ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.Text> currentValue, ml.shifu.guagua.worker.WorkerContext<LogisticRegressionParams,LogisticRegressionParams> context)- Specified by:
loadin classml.shifu.guagua.worker.AbstractWorkerComputable<LogisticRegressionParams,LogisticRegressionParams,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,ml.shifu.guagua.hadoop.io.GuaguaWritableAdapter<org.apache.hadoop.io.Text>>
-
-