-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass key instead of seed to algorithms with randomization #103
Comments
Let's try to apply this to one model and see how it looks like? Perhaps we can allow one of key or seed to be given? |
I'd rather just allow |
@polvalente but it makes the API harder to use for everyone, doesn't it? |
I don't think it does. If the key is optional, it's just what we have now. If we accept a seed, it's much harder to use than a key in terms of defn usage because the natural System.system_time call isn't available as well. I don't see any normal use case where a seed is really needed instead of a key. Also, we need to either return the key or teach people to split the key beforehand. |
That's exactly the point of how it makes it harder. For example, if you write a notebook, you may want to hardcode the seed in the notebook. But now we have to tell them to create a key before hand and split it? |
Split is only needed if you don't return the key, which I think is the preferred approach. |
Right, so we either have to return the key in all APIs or the user has to split before hand instead of passing a seed. All of those look like more work to me than just passing an integer. :) Plus, we may end-up generating the key outside of a |
How does generating the key outside of defn affect performance? |
@polvalente all of the Nx code to generate the key will be executed outside of |
Nah, ignore me. |
So I guess for the cases we don't need to split, we just need to replace |
key must be a tensor input, though, because it is split and carried over multiple computations |
Can you please expand, so we are in the same page? |
Imagine we're using one of Scholar's algorithms that needs to receive a random key in the middle of some defn code. If the previous code already used the key, it'll have a computation graph associated with it, even if it's just a sequence of splits. And from my understanding, passing that as an option would be bad for the Nx compiler. |
We handle this today in Scholar by defining all |
Nice, so I'm ok with having key as option! |
Alright, so |
If we want this functionality I can implement this.
The text was updated successfully, but these errors were encountered: