1、keras_contrib安装
https://github.com/keras-team/keras-contrib
下载后将keras_contrib文件夹放到python的\Lib\site-packages里面
2、报错The added layer must be an instance of class Layer. Found: <keras_contrib.la
要统一导入方式,tensorflow.keras、keras引用混合
3、统一用keras导入
报错module 'tensorflow.python.framework.ops' has no attribute '_TensorLike'
原因:TensorFlow和keras版本不统一报错,原tf版本2.4,keras版本2.3.1,将tf降低到2.1.0
4、报错Tensors in list passed to 'values' of 'ConcatV2' Op have types [bool, float3
参考https://blog.csdn.net/u011740601/article/details/103800575
module 'tensorflow' has no attribute 'to_float'
加上tf.to_float = lambda x: tf.cast(x, tf.float32) 参考https://ask.csdn.net/questions/2962902
修改keras_contrib的keras_contrib\layers\cfr.py,
import tensorflow as tf tf.to_float = lambda x: tf.cast(x, tf.float32)
if mask is not None: # mask2 = K.cast(K.concatenate([mask, K.zeros_like(mask[:, :1])], axis=1), # K.floatx())#改为下面的 mask2 = K.cast(K.concatenate([tf.to_float(mask), K.zeros_like(mask[:, :1])], axis=1), K.floatx()) constants.append(mask2)