Hello, I am new to Edward. I tried running Dustin’s sample coin flipping example, and keep running into an Assertion Error with ed.complete_conditional§. I also run into the same error in completely separate code. What am I doing wrong? Thanks for any guidance. Ikib
from future import absolute_import
from future import division
from future import print_function
import edward as ed
import numpy as np
import six
import tensorflow as tf
from edward.models import Bernoulli, Beta
tf.reset_default_graph()
ed.set_seed(42)
def main(_):
DATA
x_data = np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 1])
MODEL
p = Beta(1.0, 1.0)
x = Bernoulli(probs=p, sample_shape=10)
COMPLETE CONDITIONAL
p_cond = ed.complete_conditional§
sess = ed.get_session()
print(‘p(probs | x) type:’, p_cond.parameters[‘name’])
param_vals = sess.run({key: val for
key, val in six.iteritems(p_cond.parameters)
if isinstance(val, tf.Tensor)}, {x: x_data})
print(‘parameters:’)
for key, val in six.iteritems(param_vals):
print(’%s:\t%.3f’ % (key, val))
if name == “main”:
tf.app.run()
AssertionError Traceback (most recent call last)
in ()
23
24 if name == “main”:
—> 25 tf.app.run()
c:\users\bikim\appdata\local\conda\conda\envs\tensorflow\lib\site-packages\tensorflow\python\platform\app.py in run(main, argv)
124 # Call the main function, passing through any arguments
125 # to the final program.
–> 126 _sys.exit(main(argv))
127
128
in main(_)
10
11 # COMPLETE CONDITIONAL
—> 12 p_cond = ed.complete_conditional§
13
14 sess = ed.get_session()
c:\users\bikim\appdata\local\conda\conda\envs\tensorflow\lib\site-packages\edward\inferences\conjugacy\conjugacy.py in complete_conditional(rv, cond_set)
156
157 scope_name = scope + str(time.time()) # ensure unique scope when copying
–> 158 log_joint_copy = copy(log_joint, swap_dict, scope=scope_name + ‘swap’)
159 nat_params = tf.gradients(log_joint_copy, s_stat_placeholders)
160
c:\users\bikim\appdata\local\conda\conda\envs\tensorflow\lib\site-packages\edward\util\random_variables.py in copy(org_instance, dict_swap, scope, replace_itself, copy_q, copy_parent_rvs)
268 # op. Therefore copy the op itself.
269 op = tensor.op
–> 270 new_op = copy(op, dict_swap, scope, True, copy_q, False)
271
272 output_index = op.outputs.index(tensor)
c:\users\bikim\appdata\local\conda\conda\envs\tensorflow\lib\site-packages\edward\util\random_variables.py in copy(org_instance, dict_swap, scope, replace_itself, copy_q, copy_parent_rvs)
314 [], # input types; will add them afterwards
315 original_op,
–> 316 op_def)
317
318 # advertise op early to break recursions
c:\users\bikim\appdata\local\conda\conda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py in init(self, node_def, g, inputs, output_types, control_inputs, input_types, original_op, op_def)
1730 # Refactor so we don’t have to do this here.
1731 grouped_inputs = self._reconstruct_sequence_inputs(
-> 1732 op_def, inputs, node_def.attr)
1733 self._c_op = _create_c_op(self._graph, node_def, grouped_inputs,
1734 control_input_ops)
c:\users\bikim\appdata\local\conda\conda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py in _reconstruct_sequence_inputs(self, op_def, inputs, attrs)
1804 i += input_len
1805
-> 1806 assert i == len(inputs)
1807 return grouped_inputs
1808
AssertionError: