oryx.core.ppl.intervene
Stay organized with collections
Save and categorize content based on your preferences.
Transforms a program into one where provided random variables are fixed.
oryx.core.ppl.intervene(
f: oryx.core.ppl.LogProbFunction
,
**observations
) -> oryx.core.ppl.LogProbFunction
Used in the notebooks
intervene
is a probabilistic program transformation that fixes the values
for certain random samples in an input program. A probabilistic program may
sample intermediate latent random variables while computing its output.
Observing those random variables converts them into deterministic constants
that are just used in the forward computation.
Random variables that are intervened are no longer random variables. This
means that if a variable x
is intervened , it will no longer appear in the
joint_sample
of a program and its log_prob
will no longer be computed as
part of a program's log_prob
.
Examples:
Simple usage:
def model(key):
return random_variable(random.normal, name='x')(key)
intervene(model, x=1.)(random.PRNGKey(0)) # => 1.
Multiple random variables:
def model(key):
k1, k2 = random.split(key)
z = random_variable(random.normal, name='z')(k1)
return z + random_variable(random.normal, name='x')(k2)
intervene(model, z=1., x=1.)(random.PRNGKey(0)) # => 2.
Args |
f
|
A probabilistic program.
|
**observations
|
A dictionary mapping string names for random variables to
values.
|
Returns |
A probabilistic program that executes its input program with provided
variables fixed to their values.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-05-23 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-05-23 UTC."],[],[]]