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

RandomVariable treats size=() as size=None #568

Closed
ricardoV94 opened this issue Jan 2, 2024 · 0 comments · Fixed by #691
Closed

RandomVariable treats size=() as size=None #568

ricardoV94 opened this issue Jan 2, 2024 · 0 comments · Fixed by #691

Comments

@ricardoV94
Copy link
Member

ricardoV94 commented Jan 2, 2024

Description

This is different than numpy

import numpy as np
import pytensor.tensor as pt

pt.random.normal([0], size=None).eval()  # array([-0.57354733])
pt.random.normal([0], size=()).eval()  # array([-2.39088062])

np.random.normal([0], size=None)  # array([0.10438181])
np.random.normal([0], size=()).eval()  # ValueError: Output size () is not compatible with broadcast dimensions of inputs (1,).

And also JAX (and probably Numba?)

import jax

jax.random.lognormal(jax.random.PRNGKey(0), sigma=jax.numpy.ones((1,)), shape=())
# parameter shapes must be broadcast-compatible with shape argument, 
# and the result of broadcasting the shapes must equal the shape argument, 
# but got result (1,) for shape argument ().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant