Skip to content

Add renormalized laplace and gaussian distribution and kernels - #162

Merged
georgematheos merged 2 commits into
gen3dfrom
gm/gen3d/renormalized_dists
Sep 11, 2024
Merged

Add renormalized laplace and gaussian distribution and kernels#162
georgematheos merged 2 commits into
gen3dfrom
gm/gen3d/renormalized_dists

Conversation

@georgematheos

Copy link
Copy Markdown
Collaborator

No description provided.

@horizon-blue horizon-blue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wow thanks for putting this together in this short amount of time! This looks great to me overall -- I just left some inline comments, most of which are just cosmetics stuff. Feel free to merge this whenever you're ready.

Comment thread src/b3d/modeling_utils.py
Comment on lines +94 to +98
p_below_low = tfp.distributions.Laplace(loc, scale).cdf(low)
p_below_high = tfp.distributions.Laplace(loc, scale).cdf(high)
log_integral_of_laplace_pdf_over_this_range = jnp.log(
p_below_high - p_below_low
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For numerical stability, perhaps we can consider using Laplace.log_cdf and Laplace. log_survival_function?

(btw also just for clarity: I think log_integral_of_laplace_pdf_over_this_range is actually referring to the integral of laplace within the range?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@horizon-blue can you please suggest the right code snippet we need to do log_cdf and log_survival_function here?

Comment thread tests/gen3d/test_pixel_color_kernels.py
def sample(self, key, latent_color, color_scale, *args, **kwargs):
return jax.vmap(
genjax.truncated_normal.sample, in_axes=(0, 0, None, None, None)
)(split(key, latent_color.shape[0]), latent_color, color_scale, 0.0, 1.0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How to you feel about usingCOLOR_MIN_VAL and COLOR_MAX_VAL instead of hard-coding the magic constant?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will do!

@georgematheos

Copy link
Copy Markdown
Collaborator Author

@horizon-blue I made the suggested changes that I knew how to make!

@georgematheos
georgematheos merged commit ac49e93 into gen3d Sep 11, 2024
@georgematheos
georgematheos deleted the gm/gen3d/renormalized_dists branch September 11, 2024 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants