Skip to content

Instantly share code, notes, and snippets.

@Nick-Harvey
Created January 29, 2017 22:14
Show Gist options
  • Save Nick-Harvey/3eab9262770bfb690730cad1fbadf9eb to your computer and use it in GitHub Desktop.
Save Nick-Harvey/3eab9262770bfb690730cad1fbadf9eb to your computer and use it in GitHub Desktop.
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1021, in _do_call
return fn(*args)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1003, in _run_fn
status, run_metadata)
File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 89, in __exit__
next(self.gen)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 469, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [1176,20] vs. [1176]
[[Node: sub = Sub[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](Add, _recv_Placeholder_1_0)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "secondtry.py", line 72, in <module>
c = sess.run(cost, feed_dict={X: X_train, Y: y_train})
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 766, in run
run_metadata_ptr)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 964, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1014, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1034, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [1176,20] vs. [1176]
[[Node: sub = Sub[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](Add, _recv_Placeholder_1_0)]]
Caused by op 'sub', defined at:
File "secondtry.py", line 53, in <module>
cost = tf.reduce_sum(tf.pow(pred-Y, 2))/(2*n_samples)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 814, in binary_op_wrapper
return func(x, y, name=name)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 2758, in sub
result = _op_def_lib.apply_op("Sub", x=x, y=y, name=name)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
op_def=op_def)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2240, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1128, in __init__
self._traceback = _extract_stack()
InvalidArgumentError (see above for traceback): Incompatible shapes: [1176,20] vs. [1176]
[[Node: sub = Sub[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](Add, _recv_Placeholder_1_0)]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment