Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zhmfan opened this issue Apr 17, 2018 · 5 comments
Open

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

zhmfan opened this issue Apr 17, 2018 · 5 comments

Comments

@zhmfan
Copy link

zhmfan commented Apr 17, 2018

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
Copy link
Author

zhmfan commented Apr 17, 2018

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

@FanhuaandLuomu
Copy link
Owner

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

@eagle-star
Copy link

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

@FanhuaandLuomu
Copy link
Owner

@liueagle 试试windows系统下

@XL2248
Copy link

XL2248 commented Jul 7, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants