Implementation of Weibull distribution#9454
Implementation of Weibull distribution#9454tonyduan wants to merge 1 commit intopytorch:masterfrom tonyduan:weibull
Conversation
torch/distributions/weibull.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/distributions/weibull.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/distributions/weibull.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/distributions/weibull.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
I'm pleasantly surprised to see a PR from you Tony. :D -Simon |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
@vishwakftw Do you think this is good to go? |
|
Yeah I took a look at this last night, looks pretty clean 👍 |
test/test_distributions.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/distributions/weibull.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/distributions/weibull.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/distributions/weibull.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
Thanks for the comments all, especially @fritzo. I've updated the code to take suggestions into account. Please take another look, when you find time. |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
torch/distributions/weibull.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
fritzo
left a comment
There was a problem hiding this comment.
Looks good after a tiny bit of cleanup.
torch/distributions/weibull.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/distributions/weibull.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
facebook-github-bot
left a comment
There was a problem hiding this comment.
@ssnl has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: This implements the two-parameter Weibull distribution, with scale $\lambda$ and shape $k$ parameters as described on [Wikipedia](https://en.wikipedia.org/wiki/Weibull_distribution). **Details** - We implement as a transformed exponential distribution, as described [here](https://en.wikipedia.org/wiki/Weibull_distribution#Related_distributions). - The `weibull_min` variance function in scipy does not yet support a vector of distributions, so our unit test uses a scalar distribution instead of a vector. Example of the bug: ``` >>> sp.stats.expon(np.array([0.5, 1, 2])).var() # fine array([1., 1., 1.]) >>> sp.stats.weibull_min(c=np.array([0.5, 1, 2])).var() # buggy Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py", line 490, in var return self.dist.var(*self.args, **self.kwds) File "/usr/local/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py", line 1242, in var res = self.stats(*args, **kwds) File "/usr/local/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py", line 1038, in stats if np.isinf(mu): ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() ``` Pull Request resolved: pytorch#9454 Differential Revision: D8863574 Pulled By: SsnL fbshipit-source-id: 1ad3e175b469eee2b6af98e7b379ea170d3d9787
Summary: This implements the two-parameter Weibull distribution, with scale $\lambda$ and shape $k$ parameters as described on [Wikipedia](https://en.wikipedia.org/wiki/Weibull_distribution). **Details** - We implement as a transformed exponential distribution, as described [here](https://en.wikipedia.org/wiki/Weibull_distribution#Related_distributions). - The `weibull_min` variance function in scipy does not yet support a vector of distributions, so our unit test uses a scalar distribution instead of a vector. Example of the bug: ``` >>> sp.stats.expon(np.array([0.5, 1, 2])).var() # fine array([1., 1., 1.]) >>> sp.stats.weibull_min(c=np.array([0.5, 1, 2])).var() # buggy Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py", line 490, in var return self.dist.var(*self.args, **self.kwds) File "/usr/local/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py", line 1242, in var res = self.stats(*args, **kwds) File "/usr/local/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py", line 1038, in stats if np.isinf(mu): ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() ``` Pull Request resolved: pytorch#9454 Differential Revision: D8863574 Pulled By: SsnL fbshipit-source-id: 1ad3e175b469eee2b6af98e7b379ea170d3d9787
This implements the two-parameter Weibull distribution, with scale$\lambda$ and shape $k$ parameters as described on Wikipedia.
Details
weibull_minvariance function in scipy does not yet support a vector of distributions, so our unit test uses a scalar distribution instead of a vector.Example of the bug: