You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in pymc3/model_graph.py
_inputs method doesn't seem to give correct set of inputs for some var and func, resulting in incomplete graph
def _inputs(self, var, func, blockers=None):
"""Get inputs to a function that are also named PyMC3 variables"""
return set([j for j in inputs([func], blockers=blockers) if j in self.var_list and j != var])
Sample script I'm running to reproduce weird behavior
from pymc3 import Model
from pymc3 import Bernoulli, Uniform
from theano import shared
import numpy as np
import pymc3 as pm
Shoot - related to #3165, I started looking at this, but have not made much progress. It is back on the top of the pile, though. (I am closing this in favor of the other issue, but still paying attention)
if j in self.var_list and j != var
Why are we comparing var when we can compare var.name
something like:
j.name in [node.name for node in self.var_list] and j.name != var.name
Description of your problem
in pymc3/model_graph.py
_inputs method doesn't seem to give correct set of inputs for some var and func, resulting in incomplete graph
def _inputs(self, var, func, blockers=None):
"""Get inputs to a function that are also named PyMC3 variables"""
return set([j for j in inputs([func], blockers=blockers) if j in self.var_list and j != var])
Sample script I'm running to reproduce weird behavior
from pymc3 import Model
from pymc3 import Bernoulli, Uniform
from theano import shared
import numpy as np
import pymc3 as pm
n_samples = 1000
x1_samples = np.random.uniform(size=(n_samples,)) > 0.4
x2_samples = np.random.uniform(size=(n_samples,)) > 0.6
noise_sample = np.random.uniform(size=(n_samples,)) > 0.9
noisy_and_samples = x1_samples * x2_samples
noisy_and_samples[noise_sample] = 1 - noisy_and_samples[noise_sample]
x1_samples_shared = shared(x1_samples.astype(np.int))
x2_samples_shared = shared(x2_samples.astype(np.int))
noisy_and_samples_shared = shared(noisy_and_samples.astype(np.int))
with Model() as noisy_and:
# inputs node factors
x1_prob = Uniform(name='x1_prob')
x2_prob = Uniform(name='x2_prob')
x1_node = Bernoulli(name='x1_node', p=x1_prob, observed=x1_samples)
x2_node = Bernoulli(name='x2_node', p=x2_prob, observed=x2_samples)
and_res = pm.Uniform('and_res', lower=x1_node * x2_node - 1e-3, upper=x1_node * x2_node + 1e-3, shape=(n_samples,),
transform=None)
noise_prob = Uniform(name='noise_prob')
noisy_and_node = Bernoulli(name='noisy_and_node',
p=and_res * (1 - noise_prob) + (1 - and_res) * noise_prob,
observed=noisy_and_samples)
dag = pm.model_to_graphviz(noisy_and)
dag.render('cond_gauss', view=True)
Detailed Description
node "and_res" has two parents - "x1_node" and "x2_node" but the corresponding edges are absent in the graph generated.
Versions and main components
The text was updated successfully, but these errors were encountered: