indiejoseph / cnn-text-classification-tf-chinese

CNN for Chinese Text Classification in Tensorflow
235 stars 108 forks source link

直接运行时候, 报错 #19

Open ghost opened 7 years ago

ghost commented 7 years ago

你好啊, 我这边直接 ./train.py 就报错了 会不会是版本不对? 0.9.0 >> 1.0.1

我的 tensorflow 版本为 1.0.1 python 为 2.7.13

Traceback (most recent call last): File "./train.py", line 76, in <module> l2_reg_lambda=FLAGS.l2_reg_lambda) File "/Users/edwardchan/projects/classification/cnn-text-classification-tf-chinese/text_cnn.py", line 75, in __init__ self.h_pool = tf.concat(3, pooled_outputs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1029, in concat dtype=dtypes.int32).get_shape( File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 637, in convert_to_tensor as_ref=False) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 702, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 110, in _constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 99, in constant tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape)) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 367, in make_tensor_proto _AssertCompatible(values, dtype) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 302, in _AssertCompatible (dtype.name, repr(mismatch), type(mismatch).__name__)) TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

indiejoseph commented 7 years ago

應該是版本問題

Meatlf commented 7 years ago

@chopperWIN 请问你这个问题解决好了吗?可以告诉我一下是如何解决的呢?

lijingpeng commented 6 years ago

@Meatlf 是版本的问题,我的版本是1.4,遇到了同样的问题 Expected int32, got list containing Tensors of type '_Message' instead 修改text_cnn.py第75行: 把tf.concat(3, pooled_outputs) 改为: tf.concat(pooled_outputs, 3)