keras-team / keras-contrib

Keras community contributions
MIT License
1.59k stars 653 forks source link

keras_contrib/layers/crf.py:463 step * m = K.slice(states[3], [0, t], [-1, 2]) AttributeError: module 'keras.backend' has no attribute 'slice' #547

Closed ghost closed 3 years ago

ghost commented 3 years ago

Keras 2.4.3 Keras-Applications 1.0.8 keras-contrib 2.0.8 keras-embed-sim 0.8.0 keras-layer-normalization 0.14.0 keras-multi-head 0.27.0 keras-pos-embd 0.11.0 keras-position-wise-feed-forward 0.6.0 Keras-Preprocessing 1.1.2 keras-radam 0.15.0 keras-self-attention 0.46.0 keras-transformer 0.38.0 tf-estimator-nightly 2.3.0.dev2020062601 tf-nightly-gpu 2.3.0rc2

could you tell me what version shoud use ?

tc9sachin12 commented 3 years ago

Keras.backend doesnt have slice operation. Instead you can go to the location where crf.py file is stored locally on your machine (this you can find mentioned in the error dialogue, i.e. /home//anaconda3/lib/python3.8/site-packages/keras_contrib/layers/crf.py) and do the following:

add the line --> import tensrflow as tf goto line where it is mentioned K.slice --> you can do a search for "slice" --> replace K.slice by tf.slice

restart the jupyter notebook session. This should work.

kewlcoder commented 3 years ago

Keras.backend doesnt have slice operation. Instead you can go to the location where crf.py file is stored locally on your machine (this you can find mentioned in the error dialogue, i.e. /home//anaconda3/lib/python3.8/site-packages/keras_contrib/layers/crf.py) and do the following:

add the line --> import tensrflow as tf goto line where it is mentioned K.slice --> you can do a search for "slice" --> replace K.slice by tf.slice

restart the jupyter notebook session. This should work.

Yea, that works. Thanks !