如题,基本环境和版本信息如下
ubuntu==22.04
tensorflow==2.6.0
bert4keras==0.11.4
python==3.9.13
在使用中,需要指定TensorFlow为2.0,即Keras使用tf.keras
import os
os.environ['TF_KERAS'] = '1'
光这个还不够,需要在原文件bert4keras的backend.py文件中更改 line17~line21
if is_tf_keras:
sys.modules['keras'] = tf.keras
import keras
import keras.backend as K
更改为
if is_tf_keras:
# sys.modules['keras'] = tf.keras
from tensorflow import keras
import tensorflow.keras.backend as K
else:
import keras
import keras.backend as K
- TensorFlow2 TensorFlow bert4keras 4keras Ubuntutensorflow2 tensorflow bert4keras 4keras bert4keras bert4keras深度4keras bert4 tensorflow2 tensorflow tensorflow-gpu tensorflow2版本 tensorflow2 tensorflow深度 事实 tensorflow2 tensorflow实战 指南 矩阵tensorflow2 tensorflow pytorch 模型tensorflow2 tensorflow方法 tensorflow2 tensorflow anaconda3 anaconda