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

pymc container generates many (seemingly irrelevant) deterministic parents and children #134

Open
emad2 opened this issue Aug 30, 2016 · 2 comments

Comments

@emad2
Copy link

emad2 commented Aug 30, 2016

I have a Bayesian network and to model it I am using containers. I have been trying to make sure that the parents/children connections are correct before I proceed, and I noticed that when using containers, pymc generates many deterministic variables that I have not defined myself. To see this, you can run the example in tutorial:

N = 10
x_0 = pymc.Normal('x_0', mu=0, tau=1)

x = np.empty(N, dtype=object)
x[0] = x_0

for i in range(1, N):
     x[i] = pymc.Normal('x_%i' % i, mu=x[i-1], tau=1)

@pymc.observed
def y(value=1, mu=x, tau=100):
    return pymc.normal_like(value, np.sum(mu**2), tau)

and then type
x[0].children
I see children of the form

pymc.PyMCObjects.Deterministic '(x_0_le_x_2)' at 0x11df54ef0

which I cannot justify. Is this normal? Would I get the same results if I fit a model but don't use containers?

@fonnesbeck
Copy link
Member

I cannot reproduce this. I get the following:

In [3]: x[0].children
Out[3]: 
{<pymc.distributions.new_dist_class.<locals>.new_class 'x_1' at 0x1045db0f0>,
 <pymc.PyMCObjects.Stochastic 'y' at 0x118cc3518>}

which is expected.

@emad2
Copy link
Author

emad2 commented Sep 7, 2016

I narrowed down the problem to Spyder (the IDE that comes with Anaconda). When I run the code in ipython console of spyder, I get the behavior. When I run it in python environment directly from terminal, everything is fine.

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

2 participants