docs/algo/softmax_on_angel_en.md
Softmax regression is also known as multivariate logistic regression, which deals with multi-classification problems through logistic regression algorithms. Unlike binary logistic regression, softmax can handle the classification problem of K categorical variables.
Given the test input x, it is assumed that the probability P(y = k|x) can be estimated of different k values for the same sample (where k = 1, ..., K). It is assumed that the output is a K-dimensional vector(the sum of the vector is 1), which represents the estimated probability value corresponding to K categories. Assume that the probability estimation function as follows:
where,
The loss function expression is as follows:
We also usually solve the above expressions in an iterative manner. Here is the gradient expression for the iterative process:
Softmax Algorithm Model The softmax algorithm consists of only a single input layer, which can be "dense" or "sparse". Like the logistic regression algorithm, the softmax model only has one output which is the classification result. The diferent point is that softmax's loss function uses softmax loss.
softmax regression training process Angel implements the gradient descent method optimization, and gets the model by iterative training. The logic of each iteration of the worker and PS is as follows:
softmax regression predict
Data fromat is set in "ml.data.type", supporting "libsvm", "dense" and "dummy" types. For details, see Angel Data Format where the "libsvm" format is as follows:
1 1:1 214:1 233:1 234:1
where the "dummy" format is as follows:
1 1 214 233 234
Submit Command Training Job
../../bin/angel-submit \
-Dml.epoch.num=20 \
-Dangel.app.submit.class=com.tencent.angel.ml.core.graphsubmit.GraphRunner \
-Dml.model.class.name=com.tencent.angel.ml.classification.SoftmaxRegression \
-Dangel.train.data.path=$traindata \
-Dangel.save.model.path=$modelout \
-Dml.feature.index.range=$featureNum \
-Dml.feature.num=$featureNum \
-Dml.data.validate.ratio=0.1 \
-Dml.data.label.trans.class="SubOneTrans" \
-Dml.data.type=libsvm \
-Dml.learn.rate=0.1 \
-Dml.learn.decay=0.5 \
-Dml.reg.l2=0.03 \
-Daction.type=train \
-Dml.num.class=$classNum \
-Dangel.workergroup.number=10 \
-Dangel.worker.memory.mb=10000 \
-Dangel.worker.task.number=1 \
-Dangel.ps.number=4 \
-Dangel.ps.memory.mb=10000 \
-Dangel.task.data.storage.level=memory \
-Dangel.job.name=angel_train
IncTraining Job
../../bin/angel-submit \
-Dml.epoch.num=20 \
-Dangel.app.submit.class=com.tencent.angel.ml.core.graphsubmit.GraphRunner \
-Dml.model.class.name=com.tencent.angel.ml.classification.SoftmaxRegression \
-Dangel.train.data.path=$traindata \
-Dangel.load.model.path=$modelout \
-Dangel.save.model.path=$modelout \
-Dml.feature.index.range=$featureNum \
-Dml.feature.num=$featureNum \
-Dml.data.validate.ratio=0.1 \
-Dml.data.label.trans.class="SubOneTrans" \
-Dml.data.type=libsvm \
-Dml.learn.rate=0.1 \
-Dml.learn.decay=0.5 \
-Dml.reg.l2=0.03 \
-Daction.type=inctrain \
-Dml.num.class=$classNum \
-Dangel.workergroup.number=10 \
-Dangel.worker.memory.mb=10000 \
-Dangel.worker.task.number=1 \
-Dangel.ps.number=4 \
-Dangel.ps.memory.mb=10000 \
-Dangel.task.data.storage.level=memory \
-Dangel.job.name=angel_inctrain
Prediction Job
../../bin/angel-submit \
-Dml.epoch.num=20 \
-Dangel.app.submit.class=com.tencent.angel.ml.core.graphsubmit.GraphRunner \
-Dml.model.class.name=com.tencent.angel.ml.classification.SoftmaxRegression \
-Dangel.predict.data.path=$predictdata \
-Dangel.load.model.path=$modelout \
-Dangel.predict.out.path=$predictout \
-Dml.feature.index.range=$featureNum \
-Dml.feature.num=$featureNum \
-Dml.data.type=libsvm \
-Daction.type=predict \
-Dml.num.class=$classNum \
-Dangel.workergroup.number=10 \
-Dangel.worker.memory.mb=10000 \
-Dangel.worker.task.number=1 \
-Dangel.ps.number=4 \
-Dangel.ps.memory.mb=10000 \
-Dangel.task.data.storage.level=memory \
-Dangel.job.name=angel_predict