refactor regression ops to nnvm interface#9540
refactor regression ops to nnvm interface#9540eric-haibin-lin merged 7 commits intoapache:masterfrom ZiyueHuang:sparse_reg
Conversation
| // inputs are in_label and out_data, outputs are data_grad and label_grad | ||
| return std::vector<std::pair<int, int> >{{1, 0}}; | ||
| }) | ||
| .set_attr<FCompute>("FCompute<cpu>", RegressionBackward<cpu, mshadow_op::minus>); |
There was a problem hiding this comment.
We can consider creating a macro (like in https://github.com/apache/incubator-mxnet/blob/master/src/operator/tensor/elemwise_binary_op.h#L554-L569) for defining regression OPs as most of the codes are similar.
| mshadow::Stream<xpu> *s = ctx.get_stream<xpu>(); | ||
| MSHADOW_REAL_TYPE_SWITCH(inputs[reg_enum::kData].type_flag_, DType, { | ||
| MXNET_ASSIGN_REQ_SWITCH(req[reg_enum::kOut], Req, { | ||
| DType* in_data = inputs[reg_enum::kData].dptr<DType>(); |
| // outputs are data_grad, label_grad | ||
| MSHADOW_REAL_TYPE_SWITCH(inputs[1].type_flag_, DType, { | ||
| MXNET_ASSIGN_REQ_SWITCH(req[0], Req, { | ||
| DType* in_label = inputs[0].dptr<DType>(); |
|
|
||
| By default, gradients of this loss function are scaled by factor `1/n`, where n is the number of training examples. | ||
| The parameter `grad_scale` can be used to change this scale to `grad_scale/n`. | ||
| By default, gradients of this loss function are scaled by factor `1/m`, where m is the number of dimensions of a training example. |
There was a problem hiding this comment.
number of dimensions is a bit confusing to me. For shape (3,4), my first thought of num dimension is two (2-D shape). Is "number of features" clearer?
| // inputs are in_label and out_data, outputs are data_grad and label_grad | ||
| return std::vector<std::pair<int, int> >{{1, 0}}; | ||
| }) | ||
| .set_attr<FCompute>("FCompute<cpu>", RegressionBackward<cpu, mshadow_op::minus>); |
|
Thanks for the comments. Updated. |
|
|
||
| By default, gradients of this loss function are scaled by factor `1/n`, where n is the number of training examples. | ||
| The parameter `grad_scale` can be used to change this scale to `grad_scale/n`. | ||
| By default, gradients of this loss function are scaled by factor `1/m`, where m is the number of features of a training example. |
There was a problem hiding this comment.
I think the word features is not very appropriate. We can use regression outputs
|
Added some minor docstring comments. The PR looks good. |
eric-haibin-lin
left a comment
There was a problem hiding this comment.
"Add unittest for MAERegressionOutput."
Where is the test?
|
Seems that I mistakenly checkout that test file... Added back. |
* refactor regression ops * fix err for instantiation of minus_sign * remove useless header file init_op.h * replace with macro and address other comments * update * minor revise docs * add mae test
* Bump 1.1 (#192) * bump * also update base.h * revert website changes * Update index.html * update news.md (#191) * Update NEWS.md * Update README.md * refactor regression ops to nnvm interface (#9540) * refactor regression ops * fix err for instantiation of minus_sign * remove useless header file init_op.h * replace with macro and address other comments * update * minor revise docs * add mae test * Update KEYS * Update NEWS.md * fixed links that were missng ndarray folder path (#9618) * Fixed 4 broken links (#9698) * Fixed 4 broken links * fixed pylint for long line disable and 1 broken link * Update NEWS.md * Update NOTICE (#9706) * revert acc changes (#9731) * Revert "avoid per-batch blocking in metric (#9636)" This reverts commit 3fe694e. * Revert "proper flatten in acc (#9619)" This reverts commit ed823b2. * Revert "use nd for accuracy calculation (#9583)" This reverts commit f5f1b91. * keep doc change * PGP keys add liuyizhi AT apache.org (#9728) * Add my key (#9736) * [REVIEW REQUIRED] Revert PR #9484 & add additional dependency licenses to LICENSE file (#9701) * Revert "[Review Required] Fixing Licenses: Cleaning up the Top Level LICENSE file (#9484)" This reverts commit 8930d96. * Some more LICENSE fixes * Adding some more packages to the LICENSE file * Adding dependencies of dependencies * update navbar model zoo link (#9749) * update navbar model zoo link * update * initial commit * clean up * refactor * fix test
* Bump 1.1 (apache#192) * bump * also update base.h * revert website changes * Update index.html * update news.md (apache#191) * Update NEWS.md * Update README.md * refactor regression ops to nnvm interface (apache#9540) * refactor regression ops * fix err for instantiation of minus_sign * remove useless header file init_op.h * replace with macro and address other comments * update * minor revise docs * add mae test * Update KEYS * Update NEWS.md * fixed links that were missng ndarray folder path (apache#9618) * Fixed 4 broken links (apache#9698) * Fixed 4 broken links * fixed pylint for long line disable and 1 broken link * Update NEWS.md * Update NOTICE (apache#9706) * revert acc changes (apache#9731) * Revert "avoid per-batch blocking in metric (apache#9636)" This reverts commit 3fe694e. * Revert "proper flatten in acc (apache#9619)" This reverts commit ed823b2. * Revert "use nd for accuracy calculation (apache#9583)" This reverts commit f5f1b91. * keep doc change * PGP keys add liuyizhi AT apache.org (apache#9728) * Add my key (apache#9736) * [REVIEW REQUIRED] Revert PR apache#9484 & add additional dependency licenses to LICENSE file (apache#9701) * Revert "[Review Required] Fixing Licenses: Cleaning up the Top Level LICENSE file (apache#9484)" This reverts commit 8930d96. * Some more LICENSE fixes * Adding some more packages to the LICENSE file * Adding dependencies of dependencies * update navbar model zoo link (apache#9749) * update navbar model zoo link * update * initial commit * clean up * refactor * fix test
* refactor regression ops * fix err for instantiation of minus_sign * remove useless header file init_op.h * replace with macro and address other comments * update * minor revise docs * add mae test
* Bump 1.1 (apache#192) * bump * also update base.h * revert website changes * Update index.html * update news.md (apache#191) * Update NEWS.md * Update README.md * refactor regression ops to nnvm interface (apache#9540) * refactor regression ops * fix err for instantiation of minus_sign * remove useless header file init_op.h * replace with macro and address other comments * update * minor revise docs * add mae test * Update KEYS * Update NEWS.md * fixed links that were missng ndarray folder path (apache#9618) * Fixed 4 broken links (apache#9698) * Fixed 4 broken links * fixed pylint for long line disable and 1 broken link * Update NEWS.md * Update NOTICE (apache#9706) * revert acc changes (apache#9731) * Revert "avoid per-batch blocking in metric (apache#9636)" This reverts commit 3fe694e. * Revert "proper flatten in acc (apache#9619)" This reverts commit ed823b2. * Revert "use nd for accuracy calculation (apache#9583)" This reverts commit f5f1b91. * keep doc change * PGP keys add liuyizhi AT apache.org (apache#9728) * Add my key (apache#9736) * [REVIEW REQUIRED] Revert PR apache#9484 & add additional dependency licenses to LICENSE file (apache#9701) * Revert "[Review Required] Fixing Licenses: Cleaning up the Top Level LICENSE file (apache#9484)" This reverts commit 8930d96. * Some more LICENSE fixes * Adding some more packages to the LICENSE file * Adding dependencies of dependencies * update navbar model zoo link (apache#9749) * update navbar model zoo link * update * initial commit * clean up * refactor * fix test
* refactor regression ops * fix err for instantiation of minus_sign * remove useless header file init_op.h * replace with macro and address other comments * update * minor revise docs * add mae test
* Bump 1.1 (apache#192) * bump * also update base.h * revert website changes * Update index.html * update news.md (apache#191) * Update NEWS.md * Update README.md * refactor regression ops to nnvm interface (apache#9540) * refactor regression ops * fix err for instantiation of minus_sign * remove useless header file init_op.h * replace with macro and address other comments * update * minor revise docs * add mae test * Update KEYS * Update NEWS.md * fixed links that were missng ndarray folder path (apache#9618) * Fixed 4 broken links (apache#9698) * Fixed 4 broken links * fixed pylint for long line disable and 1 broken link * Update NEWS.md * Update NOTICE (apache#9706) * revert acc changes (apache#9731) * Revert "avoid per-batch blocking in metric (apache#9636)" This reverts commit 3fe694e. * Revert "proper flatten in acc (apache#9619)" This reverts commit ed823b2. * Revert "use nd for accuracy calculation (apache#9583)" This reverts commit f5f1b91. * keep doc change * PGP keys add liuyizhi AT apache.org (apache#9728) * Add my key (apache#9736) * [REVIEW REQUIRED] Revert PR apache#9484 & add additional dependency licenses to LICENSE file (apache#9701) * Revert "[Review Required] Fixing Licenses: Cleaning up the Top Level LICENSE file (apache#9484)" This reverts commit 8930d96. * Some more LICENSE fixes * Adding some more packages to the LICENSE file * Adding dependencies of dependencies * update navbar model zoo link (apache#9749) * update navbar model zoo link * update * initial commit * clean up * refactor * fix test
Description
refactor regression operators to nnvm interface (then I will add sparse support for these operators in a separate PR later).
Fix the docs. Please see #9528.
Add unittest for
MAERegressionOutput.cc @eric-haibin-lin @sxjscience
Checklist
Essentials
make lint)Changes
LinearRegressionOutputandLogisticRegressionOutput. Add unittest forMAERegressionOutput.Comments