Thanks for pointing out the tensorflow multinomial implementation, this will 
cover my use case perfectly.

 

The documentation on raises is redundant as well, the relevant information is 
mentioned in the parameter description. I’ve closed the PR.

 

Cheers,

Alex

 

 

 

From: NumPy-Discussion [mailto:numpy-discussion-boun...@scipy.org] On Behalf Of 
Stephan Hoyer
Sent: Monday, September 26, 2016 11:59 AM
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] PR 8053 np.random.multinomial tolerance param

 

I would actually be just as happy to relax the tolerance here to 1e-8 always. I 
doubt this would catch any fewer bugs than the current default. In contrast, 
adding new parameters adds cognitive overload for everyone encountering the 
function.

 

Also, for your use case note that tensorflow has it's own function for 
generating random values from a multinomial distribution:

https://www.tensorflow.org/versions/r0.10/api_docs/python/constant_op.html#multinomial

 

On Mon, Sep 26, 2016 at 11:52 AM, Alex Beloi <a.be...@samsung.com> wrote:

Hello,

 

Pull Request: https://github.com/numpy/numpy/pull/8053

 

I would like to expose a tolerance parameter for the function 
numpy.random.multinomial.

 

The function `multinomial(n, pvals, size=None)` correctly raises exception when 
`sum(pvals) > 1 + 1e-12` as these values should sum to 1. However, other 
libraries often cannot or do not guarantee such level of precision.

 

Specifically, I have encountered issues with tensorflow function tf.nn.softmax, 
which is expected to output a tensor whose values sum to 1, but often with 
precision of only 1e-8. 

 

I propose to expose the `1e-12` tolerance to a non-negative float parameter 
with default value `1e-12`.

 

Alex


_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion

 

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to