Closed KhawajaAbaid closed 10 months ago
Sounds good, we can add them. If you're able, please send a PR.
Thank you. I'll create a PR in a few minutes as I've pretty much already implemented everything. :D
I've created a PR at https://github.com/keras-team/keras/pull/18920
(Really sorry, it took longer than I thought)
Hi @KhawajaAbaid ,
As the proposed PR got merged could you please mark this issue as resolved. Thanks!
Yes sure. Thanks for the reminder.
Hi, while working on my project that is based on keras I realized that the
keras.random
module is missing the two distribution functions that I need in my project, namelybeta
andbinomial
, So, I've implemented these two functions in all four backends currently being supported by Keras, i.e. TensorFlow, Jax, PyTorch and Numpy.I've created gists of these implementations for review's sake before creating a PR as recommended by the guidelines:
Please note that as tensorflow doesn't offer a built-in method for beta function so I've implemented a workaround using a statistical formula to use gamma distributed random variables to derive beta distributed random variable. Specifically, $U(a, b) = X(a) / (X(a) + Y(b))$ where $U(a,b)$ is the beta distributed random variable using parameters $a$ and $b$ and $X(a)$ and $Y(b)$ are gamma-distributed random variables using parameter $a$ and $b$ respectively.
I think having these two functions part of the
keras.random
module will greatly help other ML practitioners as they won't have to implement all these variants of these functions to take advantage of backend agnosticism of Keras in their projects.