Closed jnoppenheim closed 7 years ago
I have a similar dimension error for the getting started example. I have only installed the library yesterday, so I haven't had time to find out what was wrong.
The error is slightly different for the getting started. There, it's an issue of an object having dimension (50,1,5) not being of rank 2.
Thanks for letting us know! It sounds like the broadcasting behavior is different. However, I'm not sure what may be leading to this issue from an Anaconda install. @evoclue: are you using Anaconda as well?
One recommendation is to use the latest version of TensorFlow (r0.10) if you aren't already. Another recommendation would be to try the git-developed version:
pip install -e "git+https://github.com/blei-lab/edward.git#egg=edward"
I'm using TensorFlow 0.10 and I just tried using edward from the git version. I'm still getting the same error.
@dustinvtran No, I installed everything using pip. I have the latest version of TF and the git version of edward.
Another error I get is in mixture_density_network.py:
X = ed.placeholder(tf.float32, shape=(None, 1))
Traceback (most recent call last):
File "<ipython-input-4-399eb3861e20>", line 1, in <module>
X = ed.placeholder(tf.float32, shape=(None, 1))
AttributeError: 'module' object has no attribute 'placeholder'
In vae.py, I get another error:
hidden = Dense(256, activation=K.relu)(z.value()) # (M, 64)
Traceback (most recent call last):
File "<ipython-input-3-99c42167c8da>", line 1, in <module>
hidden = Dense(256, activation=K.relu)(z.value()) # (M, 64)
File "/usr/local/lib/python2.7/dist-packages/edward/models/random_variables.py", line 46, in value
return self._value
AttributeError: 'Normal' object has no attribute '_value'
I haven't tried all the examples.
Not sure if it would help, but here is my pip list
:
adium-theme-ubuntu (0.3.4)
apt-xapian-index (0.45)
backports-abc (0.4)
backports.shutil-get-terminal-size (1.0.0)
backports.ssl-match-hostname (3.5.0.1)
certifi (2016.8.31)
chardet (2.0.1)
colorama (0.2.5)
command-not-found (0.3)
configparser (3.5.0)
cycler (0.10.0)
debtagshw (0.1)
decorator (4.0.10)
defer (1.0.6)
dirspec (13.10)
docutils (0.11)
duplicity (0.6.23)
edward (1.1.1, /usr/local/lib/python2.7/dist-packages)
entrypoints (0.2.2)
enum34 (1.1.6)
funcsigs (1.0.2)
functools32 (3.2.3.post2)
html5lib (0.999)
httplib2 (0.8)
ipykernel (4.5.0)
ipython (5.1.0)
ipython-genutils (0.1.0)
ipywidgets (5.2.2)
Jinja2 (2.7.2)
jsonschema (2.5.1)
jupyter (1.0.0)
jupyter-client (4.4.0)
jupyter-console (5.0.0)
jupyter-core (4.2.0)
Keras (1.1.0)
lockfile (0.8)
lxml (3.3.3)
MarkupSafe (0.18)
matplotlib (1.5.3)
mistune (0.7.3)
mock (2.0.0)
mpmath (0.19)
nbconvert (4.2.0)
nbformat (4.1.0)
nose (1.3.1)
notebook (4.2.3)
numpy (1.11.1)
oauthlib (0.6.1)
oneconf (0.3.7.14.4.1)
PAM (0.4.2)
pathlib2 (2.1.0)
pbr (1.10.0)
pexpect (4.2.1)
pickleshare (0.7.4)
Pillow (2.3.0)
pip (8.1.2)
piston-mini-client (0.7.5)
progressbar (2.3)
prompt-toolkit (1.0.7)
protobuf (3.0.0b2)
ptyprocess (0.5.1)
pycrypto (2.6.1)
pycups (1.9.66)
Pygments (2.1.3)
pygobject (3.12.0)
pyOpenSSL (0.13)
pyparsing (2.1.9)
pyserial (2.6)
pysmbc (1.0.14.1)
python-apt (0.9.3.5ubuntu2)
python-dateutil (2.5.3)
python-debian (0.1.21-nmu2ubuntu2)
pytz (2016.6.1)
pyxdg (0.25)
PyYAML (3.12)
pyzmq (15.4.0)
qtconsole (4.2.1)
reportlab (3.0)
requests (2.2.1)
roman (2.0.0)
scikit-learn (0.17.1)
scipy (0.18.1)
sessioninstaller (0.0.0)
setuptools (27.3.0)
simplegeneric (0.8.1)
singledispatch (3.4.0.3)
six (1.10.0)
sklearn (0.0)
software-center-aptd-plugins (0.0.0)
Sphinx (1.2.2)
spyder (2.3.9)
sympy (1.0)
system-service (0.1.6)
tensorflow (0.10.0)
terminado (0.6)
Theano (0.8.2)
tornado (4.4.1)
traitlets (4.3.0)
Twisted-Core (13.2.0)
Twisted-Web (13.2.0)
unity-lens-photos (1.0)
urllib3 (1.7.1)
wcwidth (0.1.7)
wheel (0.29.0)
widgetsnbextension (1.2.6)
xdiagnose (3.6.3build2)
zope.interface (4.0.5)
Following @evoclue's note, it does sound like the latest Edward version is not being used.
Can you try the following?
import edward as ed
print(ed.placeholder)
ed.placeholder
is a utility function that should be available.
In [4]: print(ed.placeholder) <function placeholder at 0x111e25140>
It appears to be available
@jnoppenheim: Can you try running mixture_density_network.py
? If it's available, then there should not be an error such as in @evoclue's note. (If it works or it errors from another line of code, then it would be worth collecting a few of these errors to see what the breaking point is; I'm not sure what would cause the dimension errors.)
@dustinvtran I had to install keras to run this. I'm getting the missing placeholder issue (see below), yet when I run edward alone I can access placeholder.
(tensorflow)Orbis:edward joppenheim$ python examples/mixture_density_network.py
Using TensorFlow backend.
Size of features in training data: (4500, 1)
Size of output in training data: (4500, 1)
Size of features in test data: (1500, 1)
Size of output in test data: (1500, 1)
Traceback (most recent call last):
File "examples/mixture_density_network.py", line 74, in
import edward as ed ed.placeholder <function placeholder at 0x111730758> exit()
It runs within ipython but not from the command line.
Actually, I can run bayesian_linear_regression through ipython too. This is very odd.
Yes that's very odd.. It sounds like a weird scoping issue. ipython and Python may be using different Python and/or package versions.
@dustinvtran I updated to 1.1.2 and now the errors are gone. Although now in the mixture_density_network.py and vae.py I get the error:
Traceback (most recent call last):
File "<ipython-input-2-9f0322278a21>", line 5, in <module>
info_dict = inference.update(feed_dict={X: X_train, y: y_train})
TypeError: update() got an unexpected keyword argument 'feed_dict'
Creating the dict outside the update function gives the error:
feed_dict={X: X_train, y: y_train}
info_dict = inference.update(feed_dict)
Traceback (most recent call last):
File "<ipython-input-6-479ee051fb52>", line 1, in <module>
info_dict = inference.update(feed_dict)
TypeError: update() takes exactly 1 argument (2 given)
I also ran the mixture_gaussian.py that @jnoppenheim got an error on, but it didn't get that error anymore, but during the inference.run(n_iter=2500, n_samples=10, n_minibatch=20)
there is an error message:
Traceback (most recent call last):
File "<ipython-input-3-31f5a4a0b474>", line 1, in <module>
inference.run(n_iter=2500, n_samples=10, n_minibatch=20)
File "/usr/local/lib/python2.7/dist-packages/edward/inferences.py", line 200, in run
loss = self.update()
File "/usr/local/lib/python2.7/dist-packages/edward/inferences.py", line 330, in update
_, loss = sess.run([self.train, self.loss])
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 710, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 908, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 958, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 978, in _do_call
raise type(e)(node_def, op, message)
InvalidArgumentError: assertion failed: [x has components greater than or equal to 1] [Condition x < y did not hold element-wise: x = ] [StopGradient_53:0] [1 2.3323967e-08] [y = ] [Dirichlet_51/log_prob/Const:0] [1]
[[Node: Dirichlet_51/log_prob/assert_less/Assert = Assert[T=[DT_STRING, DT_STRING, DT_STRING, DT_FLOAT, DT_STRING, DT_STRING, DT_FLOAT], summarize=3, _device="/job:localhost/replica:0/task:0/cpu:0"](Dirichlet_51/log_prob/assert_less/All/_3962, Dirichlet_51/log_prob/assert_less/Assert/data_0, Dirichlet_51/log_prob/assert_less/Assert/data_1, Dirichlet_51/log_prob/assert_less/Assert/data_2, StopGradient_53/_3964, Dirichlet_51/log_prob/assert_less/Assert/data_4, Dirichlet_51/log_prob/assert_less/Assert/data_5, Dirichlet_51/log_prob/Const/_3966)]]
[[Node: MultivariateNormalDiag_57/log_pdf/OperatorPDSqrtDiag_1/vector_space_dimension/Gather/_3336 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_6978_MultivariateNormalDiag_57/log_pdf/OperatorPDSqrtDiag_1/vector_space_dimension/Gather", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/gpu:0"]()]]
Caused by op u'Dirichlet_51/log_prob/assert_less/Assert', defined at:
File "/usr/local/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/start_ipython_kernel.py", line 205, in <module>
__ipythonkernel__.start()
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelapp.py", line 474, in start
ioloop.IOLoop.instance().start()
File "/usr/local/lib/python2.7/dist-packages/zmq/eventloop/ioloop.py", line 162, in start
super(ZMQIOLoop, self).start()
File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 887, in start
handler_func(fd_obj, events)
File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "/usr/local/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "/usr/local/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 276, in dispatcher
return self.dispatch_shell(stream, msg)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 228, in dispatch_shell
handler(stream, idents, msg)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 390, in execute_request
user_expressions, allow_stdin)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/ipkernel.py", line 196, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/zmqshell.py", line 501, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2717, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2827, in run_ast_nodes
if self.run_code(code, result):
File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-31f5a4a0b474>", line 1, in <module>
inference.run(n_iter=2500, n_samples=10, n_minibatch=20)
File "/usr/local/lib/python2.7/dist-packages/edward/inferences.py", line 198, in run
self.initialize(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/edward/inferences.py", line 414, in initialize
return super(MFVI, self).initialize(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/edward/inferences.py", line 297, in initialize
loss = self.build_loss()
File "/usr/local/lib/python2.7/dist-packages/edward/inferences.py", line 462, in build_loss
return self.build_score_loss()
File "/usr/local/lib/python2.7/dist-packages/edward/inferences.py", line 493, in build_score_loss
qz.log_prob(tf.stop_gradient(z_sample[z])))
File "/usr/local/lib/python2.7/dist-packages/edward/models/random_variable.py", line 99, in log_prob
return self.distribution.log_prob(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/distributions/python/ops/dirichlet.py", line 333, in log_prob
x = self._check_x(x)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/distributions/python/ops/dirichlet.py", line 397, in _check_x
] if self.validate_args else []
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/check_ops.py", line 354, in assert_less
return logging_ops.Assert(condition, data, summarize=summarize)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/logging_ops.py", line 58, in Assert
return gen_logging_ops._assert(condition, data, summarize, name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_logging_ops.py", line 37, in _assert
summarize=summarize, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 710, in apply_op
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2317, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1239, in __init__
self._traceback = _extract_stack()
Perfect! Glad the latest version fixed it.
re:MDN example. The update
API changed just a few days ago to include feed_dict
(#253). You can run _, loss = sess.run([inference.train, inference.loss], feed_dict=...)
instead of inference.update(feed_dict=...)
to get the same result. The API change to update
is not in the latest package version but it is available in the latest development version.
re:mixture gaussian example. Looks like it's the result of numerical instability. I came across that a few times during particular settings of the algorithm parameters. You can see it in the error here, [1 2.3323967e-08]
. The algorithm is trying to calculate the Dirichlet log-density of a probability vector which is essentially degenerate.
Hi! I'm trying the tf_mixture_gaussian.py example and I have the same error as @evoclue.
I have these packages in my virtualenv: backports.shutil-get-terminal-size==1.0.0 cycler==0.10.0 decorator==4.0.10 -e git+https://github.com/blei-lab/edward.git@6b2961cdde04923ffee931127f402ed1f1475c28#egg=edward enum34==1.1.6 funcsigs==1.0.2 ipython==5.1.0 ipython-genutils==0.1.0 Keras==1.1.0 matplotlib==1.5.3 mock==2.0.0 numpy==1.11.1 pathlib2==2.1.0 pbr==1.10.0 pexpect==4.2.1 pickleshare==0.7.4 prompt-toolkit==1.0.7 protobuf==3.0.0b2 ptyprocess==0.5.1 Pygments==2.1.3 pyparsing==2.1.9 python-dateutil==2.5.3 pytz==2016.6.1 PyYAML==3.12 scipy==0.18.1 simplegeneric==0.8.1 six==1.10.0 tensorflow==0.10.0 Theano==0.8.2 traitlets==4.3.0 wcwidth==0.1.7
Tensorflow 0.10 and the developer version of Edward. And this is the error:
Traceback (most recent call last): File "prueba.py", line 143, in <module> inference.run(n_iter=2500, n_samples=10, n_minibatch=20) File "/home/alberto/.virtualenvs/analytics3/src/edward/edward/inferences/inference.py", line 137, in run info_dict = self.update() File "/home/alberto/.virtualenvs/analytics3/src/edward/edward/inferences/variational_inference.py", line 167, in update _, t, loss = sess.run([self.train, self.increment_t, self.loss], feed_dict) File "/home/alberto/.virtualenvs/analytics3/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 710, in run run_metadata_ptr) File "/home/alberto/.virtualenvs/analytics3/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 908, in _run feed_dict_string, options, run_metadata) File "/home/alberto/.virtualenvs/analytics3/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 958, in _do_run target_list, options, run_metadata) File "/home/alberto/.virtualenvs/analytics3/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 978, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors.InvalidArgumentError: assertion failed: [x has components greater than or equal to 1] [Condition x < y did not hold element-wise: x = ] [StopGradient_4:0] [2.3459968e-08 1] [y = ] [Dirichlet_3/log_prob/Const:0] [1] [[Node: Dirichlet_3/log_prob/assert_less/Assert = Assert[T=[DT_STRING, DT_STRING, DT_STRING, DT_FLOAT, DT_STRING, DT_STRING, DT_FLOAT], summarize=3, _device="/job:localhost/replica:0/task:0/cpu:0"](Dirichlet_3/log_prob/assert_less/All, Dirichlet_3/log_prob/assert_less/Assert/data_0, Dirichlet_3/log_prob/assert_less/Assert/data_1, Dirichlet_3/log_prob/assert_less/Assert/data_2, StopGradient_4, Dirichlet_3/log_prob/assert_less/Assert/data_4, Dirichlet_3/log_prob/assert_less/Assert/data_5, Dirichlet_3/log_prob/Const)]] Caused by op u'Dirichlet_3/log_prob/assert_less/Assert', defined at: File "prueba.py", line 143, in <module> inference.run(n_iter=2500, n_samples=10, n_minibatch=20) File "/home/alberto/.virtualenvs/analytics3/src/edward/edward/inferences/inference.py", line 135, in run self.initialize(*args, **kwargs) File "/home/alberto/.virtualenvs/analytics3/src/edward/edward/inferences/klqp.py", line 53, in initialize return super(KLqp, self).initialize(*args, **kwargs) File "/home/alberto/.virtualenvs/analytics3/src/edward/edward/inferences/variational_inference.py", line 128, in initialize loss = self.build_loss() File "/home/alberto/.virtualenvs/analytics3/src/edward/edward/inferences/klqp.py", line 101, in build_loss return build_score_loss(self) File "/home/alberto/.virtualenvs/analytics3/src/edward/edward/inferences/klqp.py", line 450, in build_score_loss qz.log_prob(tf.stop_gradient(z_sample[z]))) File "/home/alberto/.virtualenvs/analytics3/src/edward/edward/models/random_variable.py", line 95, in log_prob return self.distribution.log_prob(*args, **kwargs) File "/home/alberto/.virtualenvs/analytics3/local/lib/python2.7/site-packages/tensorflow/contrib/distributions/python/ops/dirichlet.py", line 333, in log_prob x = self._check_x(x) File "/home/alberto/.virtualenvs/analytics3/local/lib/python2.7/site-packages/tensorflow/contrib/distributions/python/ops/dirichlet.py", line 397, in _check_x ] if self.validate_args else [] File "/home/alberto/.virtualenvs/analytics3/local/lib/python2.7/site-packages/tensorflow/python/ops/check_ops.py", line 354, in assert_less return logging_ops.Assert(condition, data, summarize=summarize) File "/home/alberto/.virtualenvs/analytics3/local/lib/python2.7/site-packages/tensorflow/python/ops/logging_ops.py", line 58, in Assert return gen_logging_ops._assert(condition, data, summarize, name) File "/home/alberto/.virtualenvs/analytics3/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_logging_ops.py", line 37, in _assert summarize=summarize, name=name) File "/home/alberto/.virtualenvs/analytics3/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 710, in apply_op op_def=op_def) File "/home/alberto/.virtualenvs/analytics3/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2317, in create_op original_op=self._default_original_op, op_def=op_def) File "/home/alberto/.virtualenvs/analytics3/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1239, in __init__ self._traceback = _extract_stack()
When I have tried in ipython it has left me the same error.
Oddly enough, I still can't run mixture_gaussian.py either for what looks like the original broadcast error. I have no problem running any other example:
ValueError Traceback (most recent call last)
/Users/joppenheim/Projects/src/edward/examples/mixture_gaussian.py in
/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/edward/inferences.pyc in run(self, _args, _kwargs)
182 Passed into initialize
.
183 """
--> 184 self.initialize(_args, _kwargs)
185 for t in range(self.n_iter + 1):
186 loss = self.update()
/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/edward/inferences.pyc in initialize(self, n_samples, score, _args, _kwargs) 365 366 self.n_samples = n_samples --> 367 return super(MFVI, self).initialize(_args, _kwargs) 368 369 def build_loss(self):
/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/edward/inferences.pyc in initialize(self, n_iter, n_minibatch, n_print, optimizer, scope, logdir) 241 zip(six.iterkeys(self.data), batches)} 242 --> 243 loss = self.build_loss() 244 if optimizer is None: 245 var_list = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES,
/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/edward/inferences.pyc in build_loss(self) 409 # return self.build_score_loss_entropy() 410 else: --> 411 return self.build_score_loss() 412 else: 413 if q_is_normal and hasattr(self.model_wrapper, 'log_lik'):
/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/edward/inferences.pyc in build_score_loss(self) 435 for key, rv in six.iteritems(self.latent_vars)} 436 --> 437 p_log_prob = self.model_wrapper.log_prob(x, z) 438 q_log_prob = 0.0 439 for key, rv in six.iteritems(self.latent_vars):
/Users/joppenheim/Projects/src/edward/examples/mixture_gaussian.py in log_prob(self, xs, zs) 82 matrix = [] 83 for k in range(self.K): ---> 84 matrix += [tf.ones(N) * tf.log(pi[k]) + 85 multivariate_normal_diag.logpdf(x, 86 mus[(k * self.D):((k + 1) * self.D)],
/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.pyc in binary_op_wrapper(x, y) 758 if not isinstance(y, ops.SparseTensor): 759 y = ops.convert_to_tensor(y, dtype=x.dtype.base_dtype, name="y") --> 760 return func(x, y, name=name) 761 762 def binary_op_wrapper_sparse(sp_x, y):
/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.pyc in _mul_dispatch(x, y, name) 907 is_tensor_y = isinstance(y, ops.Tensor) 908 if is_tensor_y: --> 909 return gen_math_ops.mul(x, y, name=name) 910 else: 911 assert isinstance(y, ops.SparseTensor) # Case: Dense * Sparse.
/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.pyc in mul(x, y, name)
1462 A Tensor
. Has the same type as x
.
1463 """
-> 1464 result = _op_def_lib.apply_op("Mul", x=x, y=y, name=name)
1465 return result
1466
/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.pyc in apply_op(self, op_type_name, name, **keywords) 701 op = g.create_op(op_type_name, inputs, output_types, name=scope, 702 input_types=input_types, attrs=attr_protos, --> 703 op_def=op_def) 704 outputs = op.outputs 705 return _Restructure(ops.convert_n_to_tensor(outputs),
/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.pyc in create_op(self, op_type, inputs, dtypes, input_types, name, attrs, op_def, compute_shapes, compute_device) 2317 original_op=self._default_original_op, op_def=op_def) 2318 if compute_shapes: -> 2319 set_shapes_for_outputs(ret) 2320 self._add_op(ret) 2321 self._record_op_seen_by_control_dependencies(ret)
/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.pyc in set_shapes_for_outputs(op) 1709 raise RuntimeError("No shape function registered for standard op: %s" 1710 % op.type) -> 1711 shapes = shape_func(op) 1712 if shapes is None: 1713 raise RuntimeError(
/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.pyc in _BroadcastShape(op) 1807 else: 1808 raise ValueError("Incompatible shapes for broadcasting: %s and %s" -> 1809 % (shape_x, shape_y)) 1810 return [tensor_shape.TensorShape(return_dims)] 1811
ValueError: Incompatible shapes for broadcasting: (20,) and (2,)
`
@bertini36: Yeah that makes sense. That example seems very sensitive as score function gradients are highly stochastic. It works for certain commits and can easily break in other commits. I'll change it to use a different algorithm.
@jnoppenheim: Possibly a cached issue? Looks like it's trying to multiply a vector of 1 with 20 elements against tf.log(pi[k])
, which for some reason is 2-dimensional and not 1-dimensional.
@dustinvtran The (20,) refers to the value of the minibatch parameter, which was one of the errors I was getting before running in ipython. I confirmed this by changing it from 5 to 20. This doesn't seem like something that should be multiplying pi, whose initial size does seem to be (2,) as it's a vector with 2 elements....
+1, I get the same error at times!
Model wrappers no longer supported.
Hi, I've had a handful of issues trying to run the mixture gaussians and the bayesian linear regression examples. For reference, I installed tensorflow through anaconda using a separate environment. I then installed edward in this environment. I can run several of the examples, but it appears that something in the normal models is causing errors.
For instance, when running mixture_gaussians.py, I end up with:
(tensorflow)Orbis:Edward joppenheim$ python mixture_gaussian.py Traceback (most recent call last): File "mixture_gaussian.py", line 144, in
inference.run(n_iter=2500, n_samples=10, n_minibatch=20)
File "/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/edward/inferences.py", line 184, in run
self.initialize(_args, _kwargs)
File "/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/edward/inferences.py", line 367, in initialize
return super(MFVI, self).initialize(_args, _kwargs)
File "/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/edward/inferences.py", line 243, in initialize
loss = self.build_loss()
File "/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/edward/inferences.py", line 411, in build_loss
return self.build_score_loss()
File "/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/edward/inferences.py", line 437, in build_score_loss
p_log_prob = self.model_wrapper.log_prob(x, z)
File "mixture_gaussian.py", line 80, in log_prob
matrix += [tf.ones(N) * tf.log(pi[k]) +
File "/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 760, in binary_op_wrapper
return func(x, y, name=name)
File "/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 909, in _mul_dispatch
return gen_math_ops.mul(x, y, name=name)
File "/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 1464, in mul
result = _op_def_lib.apply_op("Mul", x=x, y=y, name=name)
File "/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 703, in apply_op
op_def=op_def)
File "/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2319, in create_op
set_shapes_for_outputs(ret)
File "/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1711, in set_shapes_for_outputs
shapes = shape_func(op)
File "/Users/joppenheim/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 1809, in _BroadcastShape
% (shape_x, shape_y))
ValueError: Incompatible shapes for broadcasting: (20,) and (2,)
That 20 comes from the n_minibatch parameter.
A similar error occurred with Bayesian Linear Regression.
Any thoughts?