-
Notifications
You must be signed in to change notification settings - Fork 0
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
Make distributions and graph talk to each other #30
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Will Graham <[email protected]>
Co-authored-by: Will Graham <[email protected]>
…nto mscroggs/normal-example
Co-authored-by: Will Graham <[email protected]>
…nto mscroggs/normal-example
outcome_node_label: str, | ||
samples: int, | ||
*, | ||
rng_key: jax.Array, |
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.
See #24
concrete_dist = self._dist.construct( | ||
**parameters, **self._constant_parameters | ||
) | ||
output[sample] = concrete_dist.sample(new_key[sample], 1)[0][0] |
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.
return concrete_dist.sample(rng_key, samples) | ||
output = np.zeros(samples) | ||
new_key = jax.random.split(rng_key, samples) | ||
for sample in range(samples): |
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.
new_key = jax.random.split(rng_key, samples) | ||
for sample in range(samples): | ||
parameters = { | ||
i: sampled_dependencies[j][sample] for i, j in self._parameters.items() |
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.
@@ -76,7 +78,7 @@ def __init__(self) -> None: | |||
"""Create a family of normal distributions.""" | |||
super().__init__(Normal, family_name="Normal") | |||
|
|||
def construct(self, mean: ArrayCompatible, cov: ArrayCompatible) -> Normal: | |||
def construct(self, mean: ArrayCompatible, cov: ArrayCompatible) -> Normal: # type: ignore # noqa: PGH003 |
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.
mypy was very unhappy with everything I tried putting here. @willGraham01: Any idea what it should be?
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.
Also, we originally had this as the following, but either ruff or mypy was not happy that the base class didn't have the *,
, but having *, **parameters
in the base class is a syntax error...
def construct(self, mean: ArrayCompatible, cov: ArrayCompatible) -> Normal: # type: ignore # noqa: PGH003 | |
def construct(self, *, mean: ArrayCompatible, cov: ArrayCompatible) -> Normal: # type: ignore # noqa: PGH003 |
Builds on top of #16.
Removes placeholder distribution classes in graph, and plugs in the proper distribution classes in their place