keras-contrib与keras版本问题小结
基于keras与keras-contrib:biLSTM+CRF的命名实体标注模型
1.ubuntun产看keras和tensorflow版本
键入python(进入python)然后输入如下命令,查看其他库的版本是一样的操作
2.改变keras版本(以2.2.2为例):
pip install --upgrade keras==2.2.2
3.报错行:import bilsm_crf_model 错误类型:ImportError: cannot import name normalize_data_format
解决方法:
- https://blog.csdn.net/weixin_39188423/article/details/83539554
将keras版本换成2.2.2,可以解决此问题,但是会引起l_lstm = Bidirectional(LSTM(128, return_sequences=True),merge_mode=‘concat’)(drop_1)此行报错TypeError: while_loop() got an unexpected keyword argument ‘maximum_iterations’(keras) - 更好的方法是:https://github.com/ekholabs/keras-contrib/commit/0dac2da8a19f34946448121c6b9c8535bfb22ce2 将keras_contrib/layers/convolutional.py中from keras.backend.common import normalize_data_format改成from keras.utils.conv_utils import normalize_data_format就ok啦
4.报错行:model.compile(‘adam’, loss=crf.loss_function, metrics=[crf.accuracy]) 错误类型:AttributeError: ‘CRF’ object has no attribute ‘_inbound_nodes’
解决方法:
将keras版本改至2.1.4