BUPTLdy / Sentiment-Analysis

Chinese Shopping Reviews sentiment analysis
http://buptldy.github.io/2016/07/20/2016-07-20-sentiment%20analysis/
352 stars 169 forks source link

训练模型的时候报错 #16

Open yuanyuanzwj opened 6 years ago

yuanyuanzwj commented 6 years ago

Traceback (most recent call last): File "/home/wj/malware/env/word2vec_test/Malware/code/malware_lstm.py", line 178, in train() File "/home/wj/malware/env/word2vec_test/Malware/code/malware_lstm.py", line 174, in train train_lstm(n_symbols, embedding_weights, x_train, y_train, x_test, y_test) File "/home/wj/malware/env/word2vec_test/Malware/code/malware_lstm.py", line 137, in train_lstm model.add(LSTM(output_dim=50, activation='sigmoid', inner_activation='hard_sigmoid')) File "/home/wj/malware/env/local/lib/python2.7/site-packages/keras/models.py", line 312, in add output_tensor = layer(self.outputs[0]) File "/home/wj/malware/env/local/lib/python2.7/site-packages/keras/engine/topology.py", line 487, in call self.build(input_shapes[0]) File "/home/wj/malware/env/local/lib/python2.7/site-packages/keras/layers/recurrent.py", line 710, in build self.W = K.concatenate([self.W_i, self.W_f, self.W_c, self.W_o]) File "/home/wj/malware/env/local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 718, in concatenate return tf.concat(axis, [to_dense(x) for x in tensors]) File "/home/wj/malware/env/local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1029, in concat dtype=dtypes.int32).get_shape( File "/home/wj/malware/env/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 639, in convert_to_tensor as_ref=False) File "/home/wj/malware/env/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 704, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "/home/wj/malware/env/local/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 113, in _constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File "/home/wj/malware/env/local/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 102, in constant tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape)) File "/home/wj/malware/env/local/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 370, in make_tensor_proto _AssertCompatible(values, dtype) File "/home/wj/malware/env/local/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 <tf.Variable 'lstm_1_W_i:0' shape=(50, 50) dtype=float32_ref> of type 'Variable' instead.

这是哪里出错呢,找不到解决办法

yuanyuanzwj commented 6 years ago

问题已经解决,把所有的版本都换成最新版本,然后修改对应的参数既可以了