FanhuaandLuomu / BiLstm_CNN_CRF_CWS

BiLstm+CNN+CRF 法律文档(合同类案件)领域分词(100篇标注样本)
384 stars 108 forks source link

AttributeError: 'CRF' object has no attribute '_inbound_nodes #2

Open zhmfan opened 6 years ago

zhmfan commented 6 years ago

2018-04-17 14:11:48.703574: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA WARNING:tensorflow:From /usr/local/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py:1188: calling reduce_sum (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version. Instructions for updating: keep_dims is deprecated, use keepdims instead bilstm_cnn_crf.py:59: UserWarning: Update your Conv1D call to the Keras 2 API: Conv1D(padding="valid", kernel_size=5, filters=50) conv=Conv1D(nb_filter=50,filter_length=2*half_window_size+1,padding='valid')(padding_layer) WARNING:tensorflow:From /usr/local/lib/python3.5/site-packages/tensorflow/python/util/deprecation.py:497: calling conv1d (from tensorflow.python.ops.nn_ops) with data_format=NHWC is deprecated and will be removed in a future version. Instructions for updating: NHWC for data_format is deprecated, use NWC instead bilstm_cnn_crf.py:64: UserWarning: The merge function is deprecated and will be removed after 08/2017. Use instead layers from keras.layers.merge, e.g. add, concatenate, etc. rnn_cnn_merge=merge([bilstm_d,dense_conv],mode='concat',concat_axis=2) /usr/local/lib/python3.5/site-packages/keras/legacy/layers.py:458: UserWarning: The Merge layer is deprecated and will be removed after 08/2017. Use instead layers from keras.layers.merge, e.g. add, concatenate, etc. name=name) WARNING:tensorflow:From /usr/local/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py:1171: calling reduce_min (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version. Instructions for updating: keep_dims is deprecated, use keepdims instead bilstm_cnn_crf.py:72: UserWarning: Update your Model call to the Keras 2 API: Model(inputs=[<tf.Tenso..., outputs=[<tf.Tenso...) model = Model(output=[crf_output], input=[word_input]) Traceback (most recent call last): File "bilstm_cnn_crf.py", line 458, in main() File "bilstm_cnn_crf.py", line 436, in main process_train(corpus_path,nb_epoch,base_model_weight) File "bilstm_cnn_crf.py", line 248, in process_train model=Bilstm_CNN_Crf(max_len,len(lexicon),len(label_2_index),embedding_weights) File "bilstm_cnn_crf.py", line 74, in Bilstm_CNN_Crf model.compile(loss=crf.loss_function,optimizer='adam',metrics=[crf.accuracy]) File "/usr/local/lib/python3.5/site-packages/keras/engine/training.py", line 850, in compile sample_weight, mask) File "/usr/local/lib/python3.5/site-packages/keras/engine/training.py", line 450, in weighted score_array = fn(y_true, y_pred) File "/usr/local/lib/python3.5/site-packages/keras_contrib/layers/crf.py", line 287, in loss assert self._inbound_nodes, 'CRF has not connected to any layer.'

zhmfan commented 6 years ago

执行python bilstm_cnn_crf.py 的时候,一直报这个错误,不知道该怎么解决

FanhuaandLuomu commented 6 years ago

@zhmfan 这是因为keras版本和keras_contrib版本不匹配,可以pip install keras==2.0.6 试试

eagle-star commented 6 years ago

我也是这样的问题,版本都对啊

FanhuaandLuomu commented 6 years ago

@liueagle 试试windows系统下

XL2248 commented 6 years ago

是后端tensorflow版本和keras版本不匹配的原因,比如keras==2.1.3 tensorflow==1.2.1没有问题,无关系统