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

Issue warning if RVs are present in derived probability graphs #6651

Merged

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Apr 5, 2023

This is problematic when using Potentials with derived quantities expressions, such as in:

with pm.Model() as m:
  x = pm.Normal("x")
  y = pm.Potential("y", pm.logp(pm.Normal.dist(x).exp(), 1.0))  # raises new warning
  m.logp()  # contains a random variable (clone of x)

Where x is not be replaced by the value variable in the Potential expression of y, leading to the wrong model logp.

I couldn't think of a clean solution, so we just give an informative warning about the problem and suggestion on how to fix it.

Note that this is not a problem in CustomDist because the logp receives the value variables already instead of the random inputs.

@ricardoV94 ricardoV94 force-pushed the warn_missing_rvs_derived_graphs branch from a8cda2c to f9e48e0 Compare April 5, 2023 09:44
@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

Merging #6651 (f9e48e0) into main (b7764dd) will decrease coverage by 0.49%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6651      +/-   ##
==========================================
- Coverage   91.96%   91.48%   -0.49%     
==========================================
  Files          94       94              
  Lines       15927    15942      +15     
==========================================
- Hits        14647    14584      -63     
- Misses       1280     1358      +78     
Impacted Files Coverage Δ
pymc/logprob/basic.py 99.15% <100.00%> (+0.12%) ⬆️

... and 6 files with indirect coverage changes

@ricardoV94 ricardoV94 changed the title Raise warning if RVs are present in derived probability graphs Issue warning if RVs are present in derived probability graphs Apr 6, 2023
Copy link
Member

@michaelosthege michaelosthege left a comment

Choose a reason for hiding this comment

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

LGTM

@ricardoV94 ricardoV94 merged commit 09dc9d0 into pymc-devs:main Apr 6, 2023
@ricardoV94 ricardoV94 deleted the warn_missing_rvs_derived_graphs branch June 5, 2023 16:13
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.

2 participants