>>> import tensorflow as tf
>>> matrix1 = tf.constant([[3,3]])
>>> matrix2 = tf.constant([[2,2]])
>>> product = tf.matmul(matrix1,matrix2)
写完后提示以下错误,新手表示看不懂。。。求助
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 686, in _call_cpp_shape_fn_impl
input_tensors_as_shapes, status)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 473, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 2 and 1 for 'MatMul_1' (op: 'MatMul') with input shapes: [1,2], [1,2].
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
product = tf.matmul(matrix1,matrix2)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1891, in matmul
a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 2436, in _mat_mul
name=name)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2958, in create_op
set_shapes_for_outputs(ret)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2209, in set_shapes_for_outputs
shapes = shape_func(op)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2159, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 627, in call_cpp_shape_fn
require_shape_fn)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 691, in _call_cpp_shape_fn_impl
raise ValueError(err.message)
ValueError: Dimensions must be equal, but are 2 and 1 for 'MatMul_1' (op: 'MatMul') with input shapes: [1,2], [1,2].
>>> with tf.Session() as sess:
result2 = sess.run(product)
print (result2)
Traceback (most recent call last):
File "<pyshell#9>", line 2, in <module>
result2 = sess.run(product)
NameError: name 'product' is not defined
>>> matrix1 = tf.constant([[3,3]])
>>> matrix2 = tf.constant([[2,2]])
>>> product = tf.matmul(matrix1,matrix2)
写完后提示以下错误,新手表示看不懂。。。求助
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 686, in _call_cpp_shape_fn_impl
input_tensors_as_shapes, status)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 473, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 2 and 1 for 'MatMul_1' (op: 'MatMul') with input shapes: [1,2], [1,2].
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
product = tf.matmul(matrix1,matrix2)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1891, in matmul
a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 2436, in _mat_mul
name=name)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2958, in create_op
set_shapes_for_outputs(ret)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2209, in set_shapes_for_outputs
shapes = shape_func(op)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2159, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 627, in call_cpp_shape_fn
require_shape_fn)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 691, in _call_cpp_shape_fn_impl
raise ValueError(err.message)
ValueError: Dimensions must be equal, but are 2 and 1 for 'MatMul_1' (op: 'MatMul') with input shapes: [1,2], [1,2].
>>> with tf.Session() as sess:
result2 = sess.run(product)
print (result2)
Traceback (most recent call last):
File "<pyshell#9>", line 2, in <module>
result2 = sess.run(product)
NameError: name 'product' is not defined
