You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/05/23 19:34:47 UTC

[GitHub] [incubator-mxnet] larroy commented on a change in pull request #14992: [MXNET-978] Support higher order gradient for `log`.

larroy commented on a change in pull request #14992: [MXNET-978] Support higher order gradient for `log`.
URL: https://github.com/apache/incubator-mxnet/pull/14992#discussion_r287101165
 
 

 ##########
 File path: src/operator/tensor/elemwise_unary_op_basic.cc
 ##########
 @@ -1069,13 +1069,72 @@ The storage type of ``log2`` output is always dense
 .set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{"_backward_log2"});
 
 MXNET_OPERATOR_REGISTER_BINARY_WITH_SPARSE_CPU_DR(_backward_log,
-                                                  unary_bwd<mshadow_op::log_grad>);
+                                                  unary_bwd<mshadow_op::log_grad>)
+.set_attr<nnvm::FGradient>("FGradient",
+  [](const nnvm::NodePtr& n, const std::vector<nnvm::NodeEntry>& ograds) {
+    // For g(x) -> g = log
+    // g''(x) = -1 * (g'(x) * g'(x))
+    auto gx = nnvm::NodeEntry{n, 0, 0};
 
 Review comment:
   You are welcome to simplify calls to NodeEntry as per:
   
   https://github.com/apache/incubator-mxnet/pull/14095
   
   Just call nnvm::NodeEntry{n}

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services