Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Unary ops logcdf_normal, derivlogcdf_normal [MXNET-39] #9982

Closed
wants to merge 1 commit into from
Closed

Unary ops logcdf_normal, derivlogcdf_normal [MXNET-39] #9982

wants to merge 1 commit into from

Conversation

mseeger
Copy link
Contributor

@mseeger mseeger commented Mar 3, 2018

  • New unary ops

  • Improved unit tests for basic unary, binary ops

Description

(Brief description on what this PR is about)

Checklist

Essentials

  • Passed code style checking (make lint)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

…ormal

* New unary ops

* Improved unit tests for basic unary, binary ops
@mseeger
Copy link
Contributor Author

mseeger commented Mar 3, 2018

Sorry, this is just #9961 reopened, I deleted the remote branch.

@piiswrong
Copy link
Contributor

Still not quite sure about the name...

@mseeger
Copy link
Contributor Author

mseeger commented Mar 6, 2018

@piiswrong Are you worried about polluting the global namespace with specific mathematical functions?

Any suggestions? Some thoughts:

  • Could move them to random namespace, as this is about functions related to random variates.
    Drawback is that random so far has only sampling ops
  • A new namespace, say stats? Drawback: Not much in there
  • An operator called "normal_funcs" with a string arg, which I can set to "logcdf", "deriv_logcdf".
    This is just a bit harder to implement, cannot use the default macros for unary ops
  • Move to contrib namespace. I'd be OK with this, but note this is just as solid as gamma or
    gammaln, there is nothing experimental about this code. I have the feeling that stuff in
    contrib is not generally trusted

These are really useful functions, MXNet should have them. Just let me know what to do.

@mseeger
Copy link
Contributor Author

mseeger commented Mar 6, 2018

If things have to be moved to a namespace, I'd need help on how to do that: I don't know how this works.

@piiswrong
Copy link
Contributor

Is this exactly the same with scipy.stats.norm.logcdf? If so maybe we call it logcdf too?
derivlogcdf is not a pretty name. Any other options?

Does any other frameworks implement these functions? tf?

@CodingCat
Copy link
Contributor

Hi, the community has passed to vote about associating the code changes with JIRA (https://lists.apache.org/thread.html/ab22cf0e35f1bce2c3bf3bec2bc5b85a9583a3fe7fd56ba1bbade55f@%3Cdev.mxnet.apache.org%3E)

We have updated the guidelines for contributors in https://cwiki.apache.org/confluence/display/MXNET/Development+Process, please ensure that you have created a JIRA at https://issues.apache.org/jira/projects/MXNET/issues/ to describe your work in this pull request and include the JIRA title in your PR as [MXNET-xxxx] your title where MXNET-xxxx is the JIRA id

Thanks!

@mseeger
Copy link
Contributor Author

mseeger commented Mar 7, 2018

@piiswrong

Tensorflow has log_cdf in tf.distributions.Normal, see
https://www.tensorflow.org/api_docs/python/tf/distributions/Normal

And yes: It is identical with scipy.stats.norm.logcdf.

Your comments:

  • We can call it logcdf, but then it is not clear it is the log CDF of the normal distribution
  • If f(x) is derivlogcdf, then f(-x) is called hazard function of the normal distribution, so one
    could call it hazard and implement f(-x)

Note: These functions sound obscure, but they serve a large number of use cases in Bayesian ML. Some examples:

  • Several acquisition functions in Bayesian optimization require them. BO is important for DNNs,
    to choose hyperparameters. The Amper team is using MXNet more and more
  • Expectation propagation inference for binary classification requires them, a very popular
    algorithm (f.ex. the BLIP algorithm used widely at Amazon)

OK: How about we move this to contrib? And if nobody except us is using it much, it can stay there. Let me know.

@mseeger mseeger changed the title Unary ops logcdf_normal, derivlogcdf_normal for log CDF of standard n… Unary ops logcdf_normal, derivlogcdf_normal [MXNET-39] Mar 7, 2018
@mseeger
Copy link
Contributor Author

mseeger commented Mar 8, 2018

Hi Eric, Marco told me contrib is not a good place, and suggested to open a new namespace (say: math) for such more specific mathematical functions. They'd be out of the way of most MXNet users, and clunkier names should be more acceptable then.

What do you think? I also wrote to dev@

@szha
Copy link
Member

szha commented Mar 8, 2018

Please make more efforts in filling out PR template.

@piiswrong
Copy link
Contributor

I think putting it in contrib is fine for now until we decide if we want a mx.distributions name space

@piiswrong
Copy link
Contributor

@mseeger ping

@mseeger
Copy link
Contributor Author

mseeger commented Mar 30, 2018

I will close this request and reopen it later when I have more time to finish it properly

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants