-
-
Save rtbs-dev/1349864212b25cce91dbe5e336d794b4 to your computer and use it in GitHub Desktop.
I get the same error with pymc3 3.6 and python3.
Traceback (most recent call last):
File "pmml_test.py", line 147, in
[gpm(BN,'D4', num=1),BN.adj['C3']['D4']['bin']], observed=BN.node['D4']['observe'])
File "/Users/fangwq/Library/Python/3.6/lib/python/site-packages/theano/tensor/var.py", line 544, in getitem
theano.tensor.subtensor.Subtensor.convert(arg)
File "/Users/fangwq/Library/Python/3.6/lib/python/site-packages/theano/tensor/subtensor.py", line 354, in convert
raise TypeError("Expected an integer")
TypeError: Expected an integer
Any help, please? Thanks!
Thanks to all above!
I have about four hours experience in pymc3, so the above comments are much appreciated.
Using networkx 2.3 and pyMC3 3.7, cpu on Windows.
Fixed the dict_keyiterator
problem.
32 BN.edge['C3']['D4']['bin'] = T.switch(T.lt(gpm(BN,'D4'),9), 0,
---> 33 T.switch(T.gt(gpm(BN,'D4'), 9) & T.lt(gpm(BN,'D4'),11), 1, 2))
AttributeError: 'DiGraph' object has no attribute 'edge'
When print(BN.__dict__)
I see no edge
attribute.
The edges seem to be embedded in _adj
, _pred
and _succ
.
BN = nx.DiGraph()
BN.add_node('D1', dtype='Discrete', prob=d1_prob, pos=(2, 4))
BN.add_node('D2', dtype='Discrete', prob=d2_prob, pos=(4, 4))
BN.add_node('C1', dtype='Continuous', mu=c1_mu, sd=c1_sd, pos=(1,3))
BN.add_edge('D1', 'C1')
print(BN.__dict__)
-----------------------------------------------
{
'graph_attr_dict_factory': <class 'dict'>, 'node_dict_factory': <class 'dict'>,
'node_attr_dict_factory': <class 'dict'>, 'adjlist_outer_dict_factory': <class 'dict'>,
'adjlist_inner_dict_factory': <class 'dict'>, 'edge_attr_dict_factory': <class 'dict'>,
'graph': {},
'_node': {
'D1': {'dtype': 'Discrete', 'prob': array([0.3, 0.7]), 'pos': (2, 4)},
'D2': {'dtype': 'Discrete', 'prob': array([0.6, 0.3, 0.1]), 'pos': (4, 4)},
'C1': {'dtype': 'Continuous', 'mu': array([10, 14]), 'sd': array([2, 2]), 'pos': (1, 3)}
},
'_adj': {'D1': {'C1': {}}, 'D2': {}, 'C1': {}},
'_pred': {'D1': {}, 'D2': {}, 'C1': {'D1': {}}},
'_succ': {'D1': {'C1': {}}, 'D2': {}, 'C1': {}}
}
D1
is a predecessor for C1
.
C1
is a successor for D1
.
But C1
is also adjacent to D1
?
My bigger issue is what to do with the error on line 32/33 above.
I have no idea how to handle this. Any help will be appreciated!
Wow, I had no idea there were comments here! Thanks to all for checking out the example. For those of you with issues/ideas (especially networkx v2 problems), check out the repository that automates a lot of the underlying mechanical/boilerplate code in this example. This notebook was really just a proof-of-concept for that repository.
I haven't gone back to the code for a while, but if there's interest I would be happy to update things to newer pymc3 features. Please see if your above issues persist in the more mature repository. Thanks!
@NelisW certainly, and like I said, feel free to open an issue if something works unexpectedly on that repo (as I said, it's been a while).
If you are having issues with BN.edges['C3']['D4']['bin']
, substitute for BN.edges['C3','D4']['bin']
.
As described in the migration guide mentioned before
G.edge have been removed in favor of using G.nodes[n] and G.edges[u, v]
Do you have any example for dynamic BN simulated on PYMC3?
I am getting the following error:
Traceback (most recent call last):
File "", line 30, in
BN.edge['C3']['D4']['bin']], observed=BN.node['D4']['observe'])
File "C:\Users\Andrea\Anaconda3\lib\site-packages\theano\tensor\var.py", line 544, in getitem
theano.tensor.subtensor.Subtensor.convert(arg)
File "C:\Users\Andrea\Anaconda3\lib\site-packages\theano\tensor\subtensor.py", line 354, in convert
raise TypeError("Expected an integer")
TypeError: Expected an integer
Any help, please? Thanks!