@创建于:2022.10.08
@修改于:2022.10.08
在建立NER识别模型 BiLSTM-CRF时出现:
TypeError: Tensors in list passed to 'values' of 'ConcatV2' Op have types [bool, float32] that don't all match.
主要是利用了keras-contrib 包,各种包的版本号如下
# python 3.7.12
tensorflow==2.2.0
keras==2.3.1
numpy==1.19.2
pandas==1.0.5
scikit-learn==0.24.1
keras-contrib==2.0.8
protobuf==3.19.0
pydot==1.4.2
pydotplus==2.0.2
# conda install graphviz
graphviz==6.0.1
根据报错信息找到crf文件,在代码前面加上
import tensorflow as tf
mask2 = K.cast(K.concatenate([tf.cast(mask, dtype=tf.float32), K.zeros_like(mask[:, :1])], axis=1), K.floatx())
#mask2 = K.cast(K.concatenate([mask, K.zeros_like(mask[:, :1])], axis=1),
# K.floatx())
2、参考链接
NER建立模型时出现concat tensors不匹配问题
Tensors in list passed to ‘values‘ of ‘ConcatV2‘ Op have types [bool, float32] that don‘t all match.
TypeError: Tensors in list passed to ‘values’ of ‘ConcatV2’ Op have types [bool, float32] that don’t