-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix obs broadcast mismatch #4700
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
Fix obs broadcast mismatch #4700
Conversation
@@ -1116,8 +1116,6 @@ def register_rv(self, rv_var, name, data=None, total_size=None, dims=None, trans | |||
): | |||
raise TypeError("Observed data cannot consist of symbolic variables.") | |||
|
|||
data = pandas_to_array(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this cause problems if a DataFrame
is passed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the first things in make_obs_var
is another call to pandas_to_array
, that's why this one can go away
@@ -156,6 +156,10 @@ def change_rv_size( | |||
size = rv_node.op._infer_shape(size, dist_params) | |||
new_size = tuple(np.atleast_1d(new_size)) + tuple(size) | |||
|
|||
# Make sure the new size is a tensor. This helps to not unnecessarily pick |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Make sure the new size is a tensor. This helps to not unnecessarily pick | |
# Make sure the new size is an int64 tensor. This helps to not unnecessarily pick |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also link to the issue here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's discoverable through the commits.
But on #4696 we'll make a few more robustness changes to change_rv_size
. I can link the issue when rebasing the reintro_shape
branch.
Unfortunately, the comment change introduced by commit 1716082 is actually more misleading than the original comment, because it makes a false statement instead of one that simply lacks context. The The Here's the clarified form of the original comment: # Make sure numeric/NumPy `new_size` values are converted to int64, so that
# the `RandomVariable`'s new `size` doesn't unnecessarily pick up a `Cast`. |
This PR casts
new_shape
values inpymc3.aesaraf.change_rv_size
before callingRandomVariable.make_node
, which prevents unnecessaryCast
s in the resultingRandomVariable
'ssize
parameter whennew_shape
is a constant.As a follow-up and/or alternative,
RandomVariable.make_node
can be updated in Aesara and accomplish the same thing.Closes #4652.