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

Allow transformation of weak vars #235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

jobrachem
Copy link
Contributor

So far, we did not allow transformation of weak vars in Var.transform. I have a usecase for that right now, and I don't think anything really speaks against allowing it. This PR makes two small changes that enable the functionality.

If you transform a weak var, it gets inserted in between the old value node and the transformed variable:

import liesel.model as lsl
import jax.numpy as jnp
import tensorflow_probability.substrates.jax.bijectors as tfb

tau = lsl.Var.new_param(10.0, name="tau")
tau_sqrt = lsl.Var.new_calc(jnp.sqrt, tau, name="tau_sqrt")
log_tau_sqrt = tau_sqrt.transform(tfb.Exp())
model = lsl.Model([tau_sqrt])
lsl.plot_vars(model)

image

@jobrachem jobrachem self-assigned this Dec 15, 2024
@jobrachem jobrachem added the comp:model This issue is related to the model module label Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:model This issue is related to the model module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant