dennybritz/chatbot-retrieval

The question about Tensorflow about Incompatible shapes: [730,5] vs. [30,5]

Opened this issue · 0 comments

im new for tensorflow,and while i am tring to run my Session,there is an error :
`Traceback (most recent call last):
File "G:\Python 3.7\lib\site-packages\tensorflow\python\client\session.py", line 1356, in _do_call
return fn(*args)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\client\session.py", line 1341, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\client\session.py", line 1429, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [730,5] vs. [30,5]
[[{{node gradients/Add_4_grad/BroadcastGradientArgs}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\ptvsd_launcher.py", line 119, in
vspd.debug(filename, port_num, debug_id, debug_options, run_as)
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\debugger.py", line 41, in debug
run(address, filename, *args, **kwargs)
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd_local.py", line 80, in run_file
run(argv, addr, **kwargs)
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd_local.py", line 140, in _run
_pydevd.main()
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd_vendored\pydevd\pydevd.py", line 2329, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd_vendored\pydevd\pydevd.py", line 1664, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd_vendored\pydevd\pydevd.py", line 1671, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd_vendored\pydevd_pydev_imps_pydev_execfile.py", line 25, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:\Users\10987\Desktop\Mission\Mission\train.py", line 20, in
main()
File "C:\Users\10987\Desktop\Mission\Mission\train.py", line 15, in main
my_network.train()
File "C:\Users\10987\Desktop\Mission\Mission\network.py", line 136, in train
self.__net.run(self.__opt, feed_dict={self.__X: self.__train_data[x], self.__Y: self.__test_data[x]})
File "G:\Python 3.7\lib\site-packages\tensorflow\python\client\session.py", line 950, in run
run_metadata_ptr)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\client\session.py", line 1173, in _run
feed_dict_tensor, options, run_metadata)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\client\session.py", line 1350, in _do_run
run_metadata)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\client\session.py", line 1370, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [730,5] vs. [30,5]
[[node gradients/Add_4_grad/BroadcastGradientArgs (defined at C:\Users\10987\Desktop\Mission\Mission\network.py:121) ]]

Original stack trace for 'gradients/Add_4_grad/BroadcastGradientArgs':
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\ptvsd_launcher.py", line 119, in
vspd.debug(filename, port_num, debug_id, debug_options, run_as)
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\debugger.py", line 41, in debug
run(address, filename, *args, **kwargs)
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd_local.py", line 80, in run_file
run(argv, addr, **kwargs)
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd_local.py", line 140, in _run
_pydevd.main()
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd_vendored\pydevd\pydevd.py", line 2329, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd_vendored\pydevd\pydevd.py", line 1664, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd_vendored\pydevd\pydevd.py", line 1671, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\Packages\ptvsd_vendored\pydevd_pydev_imps_pydev_execfile.py", line 25, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:\Users\10987\Desktop\Mission\Mission\train.py", line 20, in
main()
File "C:\Users\10987\Desktop\Mission\Mission\train.py", line 15, in main
my_network.train()
File "C:\Users\10987\Desktop\Mission\Mission\network.py", line 121, in train
self.__opt = tf.train.AdamOptimizer().minimize(self.__mse)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\training\optimizer.py", line 403, in minimize
grad_loss=grad_loss)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\training\optimizer.py", line 512, in compute_gradients
colocate_gradients_with_ops=colocate_gradients_with_ops)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\ops\gradients_impl.py", line 158, in gradients
unconnected_gradients)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\ops\gradients_util.py", line 731, in _GradientsHelper
lambda: grad_fn(op, *out_grads))
File "G:\Python 3.7\lib\site-packages\tensorflow\python\ops\gradients_util.py", line 403, in _MaybeCompile
return grad_fn() # Exit early
File "G:\Python 3.7\lib\site-packages\tensorflow\python\ops\gradients_util.py", line 731, in
lambda: grad_fn(op, *out_grads))
File "G:\Python 3.7\lib\site-packages\tensorflow\python\ops\math_grad.py", line 1004, in _AddGrad
rx, ry = gen_array_ops.broadcast_gradient_args(sx, sy)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 1004, in broadcast_gradient_args
"BroadcastGradientArgs", s0=s0, s1=s1, name=name)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\framework\ops.py", line 3616, in create_op
op_def=op_def)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\framework\ops.py", line 2005, in init
self._traceback = tf_stack.extract_stack()

...which was originally created as op 'Add_4', defined at:
File "d:\vs2019\common7\ide\extensions\microsoft\python\core\ptvsd_launcher.py", line 119, in
vspd.debug(filename, port_num, debug_id, debug_options, run_as)
[elided 8 identical lines from previous traceback]
File "C:\Users\10987\Desktop\Mission\Mission\train.py", line 15, in main
my_network.train()
File "C:\Users\10987\Desktop\Mission\Mission\network.py", line 117, in train
self.__out = tf.transpose(tf.add(tf.matmul(locals()['self._hidden' + str(self.__l_num)], self.__W_out), self.__bias_out))
File "G:\Python 3.7\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 396, in add
"Add", x=x, y=y, name=name)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\framework\ops.py", line 3616, in create_op
op_def=op_def)
File "G:\Python 3.7\lib\site-packages\tensorflow\python\framework\ops.py", line 2005, in init
self._traceback = tf_stack.extract_stack()`

and my input shape is [730,7],output shape is [30,5],
self.__out = tf.transpose(tf.add(tf.matmul(locals()['self.__hidden_' + str(self.__l_num)], self.__W_out), self.__bias_out)) self.__mse = tf.reduce_mean(tf.math.squared_difference(tf.transpose(self.__out), self.__Y)) self.__opt = tf.train.AdamOptimizer().minimize(self.__mse)
and i dont know how to fix it,thanks for the help