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

How to query deterministic transformations of StochasticTensor? #41

Closed
meta-inf opened this issue May 12, 2017 · 3 comments
Closed

How to query deterministic transformations of StochasticTensor? #41

meta-inf opened this issue May 12, 2017 · 3 comments

Comments

@meta-inf
Copy link
Member

Hi,

I'm implementing a model in which I need $f_{MLP}(z)$ in inference. As BayesianNet.query only accepts StochasticTensor, is there any way to do this, or could you consider adding this feature (e.g. by adding a deterministic StochasticTensor wrapper)? I think it's a pretty common use case.

Thanks for the awesome work!

@wmyw96
Copy link
Collaborator

wmyw96 commented May 12, 2017

Suppose you want to perform transform on $w$, you can get the samples and log_probs of $w$ from BayesianNet.query, modify them by $f_{MLP}(z)$ defined by you own, and the use the transformed samples and log_probs in inference algorithm. Moreover, we implement the Normalizing Flow in examples/normalizing_flows, you can refer to it as examples.

@meta-inf
Copy link
Member Author

Thanks. Guess I'm a bit unconscious now ...

@thjashin
Copy link
Collaborator

thjashin commented May 13, 2017

@meta-inf The case is that when you do deterministic transformation, unless it's invertible (one-to-one), there is no easy way to compute the transformed probability. But getting its sample is easy. You could just return it from your model building code.

def build_model():
    with zs.BayesianNet() as model:
        a = zs.Normal('a')
        # deterministic transform 
        b = f(a)
    return model, b

For invertible mapping, we provided some support from the recent literature (normalizing flow: http://proceedings.mlr.press/v37/rezende15.pdf)

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

No branches or pull requests

3 participants