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

Support PyTensor deterministic operations as observations #7656

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

wd60622
Copy link
Contributor

@wd60622 wd60622 commented Jan 24, 2025

Description

Will need some help on this implementation and how to best test this.

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

📚 Documentation preview 📚: https://pymc--7656.org.readthedocs.build/en/7656/

@github-actions github-actions bot added the bug label Jan 24, 2025
pymc/data.py Outdated Show resolved Hide resolved
pymc/data.py Outdated Show resolved Hide resolved
@ricardoV94
Copy link
Member

We need to tell InferenceData converter how to get the data values to put in constant_data, and observed_data. It had some hardcode logic assuming you could only due Casts

@ricardoV94
Copy link
Member

I don't consider this a bugfix, it's behavior that was explicitly forbidden for conservative reasons (more like a NotImplementedError)

@wd60622
Copy link
Contributor Author

wd60622 commented Jan 25, 2025

We need to tell InferenceData converter how to get the data values to put in constant_data, and observed_data. It had some hardcode logic assuming you could only due Casts

Where does this happen in the code?

@wd60622
Copy link
Contributor Author

wd60622 commented Jan 25, 2025

I think the MiniBatch tests will still fail. Any thoughts on how that should behave?

@wd60622
Copy link
Contributor Author

wd60622 commented Jan 25, 2025

Also, feel free to choose a better title! I couldn't express it too well

scale = 12
scaled_target = target / scale
mu = pm.Normal("mu", mu=0, sigma=1)
pm.Normal("x", mu=mu, sigma=1, observed=scaled_target)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I sample this to check that it has the correct data in the InferenceData?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we have more direct ways of testing it

@ricardoV94
Copy link
Member

ricardoV94 commented Jan 25, 2025

We need to tell InferenceData converter how to get the data values to put in constant_data, and observed_data. It had some hardcode logic assuming you could only due Casts

Where does this happen in the code?

obs_data = extract_obs_data(aux_obs)

def extract_obs_data(x: TensorVariable) -> np.ndarray:

We should be able to just use constant_fold (also in pytensor) for it

@ricardoV94 ricardoV94 changed the title Support ops to pm.Data in observed variables Support pytensor deterministic operations as observations Jan 25, 2025
@ricardoV94 ricardoV94 changed the title Support pytensor deterministic operations as observations Support PyTensor deterministic operations as observations Jan 25, 2025
@wd60622
Copy link
Contributor Author

wd60622 commented Jan 25, 2025

We should be able to just use constant_fold (also in pytensor) for it

I have an implementation before this suggestion. I need a little help understanding this. Feel free to put suggestion

@ricardoV94
Copy link
Member

We should be able to just use constant_fold (also in pytensor) for it

I have an implementation before this suggestion. I need a little help understanding this. Feel free to put suggestion

What do you mean? My suggestion is to simply call constant_fold on the observed variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: data as observed in RV
2 participants