Skip to content
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

Create a RandomState Variable constructor Op #739

Closed
brandonwillard opened this issue Jan 10, 2022 · 6 comments · Fixed by #789
Closed

Create a RandomState Variable constructor Op #739

brandonwillard opened this issue Jan 10, 2022 · 6 comments · Fixed by #789
Labels
enhancement New feature or request help wanted Extra attention is needed important random variables Involves random variables and/or sampling

Comments

@brandonwillard
Copy link
Member

We need an Op that will construct RandomState Variables with the seed values as inputs.

We should need only one such Op that handles all RandomState types (e.g. by having a fixed Op-level property that determines which types the Op generates).

This—combined with #738—will largely remove the need to use shared variables for RNG states.

@brandonwillard brandonwillard added enhancement New feature or request important new operator random variables Involves random variables and/or sampling help wanted Extra attention is needed labels Jan 10, 2022
@ricardoV94
Copy link
Contributor

I like that approach. It sounds a lot like what we ended up doing here manually with shared RandomState variables: https://github.com/pymc-devs/pymc/blob/b29124bc054c47ca2de99789d9894db0caa17c13/pymc/initial_point.py#L200-L219

@brandonwillard
Copy link
Member Author

I like that approach. It sounds a lot like what we ended up doing here manually with shared RandomState variables: https://github.com/pymc-devs/pymc/blob/b29124bc054c47ca2de99789d9894db0caa17c13/pymc/initial_point.py#L200-L219

Another way to put it: we need an Op for numpy.random.default_rng.

@kc611
Copy link
Contributor

kc611 commented Jan 23, 2022

Took a stab at this and ran into an obvious problem. How do we return a symbolic representation of a SharedVariable (RandomStateSharedVariables in this case) in the Op.make_node without providing it a value in Op.make_node itself ?

@brandonwillard
Copy link
Member Author

brandonwillard commented Jan 23, 2022

Took a stab at this and ran into an obvious problem. How do we return a symbolic representation of a SharedVariable (RandomStateSharedVariables in this case) in the Op.make_node without providing it a value in Op.make_node itself ?

There are no shared variables in this case. That's why we want this Op.

@kc611
Copy link
Contributor

kc611 commented Jan 23, 2022

Do we return Variable that can contain/return RandomState symbolically?

I am having trouble understanding how such an Op will be made with current Variable classes.

@brandonwillard
Copy link
Member Author

Yeah, a plain Variable can be used, but it might be better to have a specific variable type. That would make it possible to do type checking on the variable instances instead of their .type class attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed important random variables Involves random variables and/or sampling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants