解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘

简介: 解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘

2022-01-14 19:10:40.281030: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
  File "E:/Code/Jupyter/mnist-tfv2/文本匹配/model.py", line 45, in <module>
    model = get_model()
  File "E:/Code/Jupyter/mnist-tfv2/文本匹配/model.py", line 34, in get_model
    score = cosine_distance(x_lstm, y_lstm)
  File "E:/Code/Jupyter/mnist-tfv2/文本匹配/model.py", line 29, in cosine_distance
    tf.div()
AttributeError: module 'tensorflow' has no attribute 'div'

问题原因:

在tensorflow2.0版本取消了tf.div()函数

解决办法:

使用2.7.0新版API

tf.math.divide()


目录
相关文章
|
2月前
|
TensorFlow 算法框架/工具 Python
【Tensorflow 2】解决'Tensor' object has no attribute 'numpy'
解决'Tensor' object has no attribute 'numpy'
43 3
|
2月前
|
TensorFlow API 算法框架/工具
【Tensorflow+keras】解决使用model.load_weights时报错 ‘str‘ object has no attribute ‘decode‘
python 3.6,Tensorflow 2.0,在使用Tensorflow 的keras API,加载权重模型时,报错’str’ object has no attribute ‘decode’
35 0
|
3月前
|
机器学习/深度学习 IDE TensorFlow
【Python】已解决ModuleNotFoundError: No module named ‘tensorflow‘
【Python】已解决ModuleNotFoundError: No module named ‘tensorflow‘
56 1
|
TensorFlow 算法框架/工具 Python
Python升级tensorflow2.x版本相关问题:No module named ‘tensorflow.contrib‘ 问题解决
Python升级tensorflow2.x版本相关问题:No module named ‘tensorflow.contrib‘ 问题解决
270 0
|
并行计算 编译器 TensorFlow
[不用回退keras版本的解决方法]AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu'
[不用回退keras版本的解决方法]AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu'
259 0
[不用回退keras版本的解决方法]AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu'
解决ModuleNotFoundError: No module named ‘tensorflow_datasets‘
解决ModuleNotFoundError: No module named ‘tensorflow_datasets‘
305 0
解决ModuleNotFoundError: No module named ‘tensorflow_datasets‘
|
TensorFlow 算法框架/工具
TensorFlow修改图像尺寸:AttributeError: module ‘tensorflow._api.v2.image‘ has no attribute ‘image‘
TensorFlow修改图像尺寸:AttributeError: module ‘tensorflow._api.v2.image‘ has no attribute ‘image‘
123 0
TensorFlow修改图像尺寸:AttributeError: module ‘tensorflow._api.v2.image‘ has no attribute ‘image‘
|
TensorFlow 算法框架/工具
成功解决AttributeError: module tensorflow.sets has no attribute intersection
成功解决AttributeError: module tensorflow.sets has no attribute intersection
成功解决AttributeError: module tensorflow.sets has no attribute intersection
|
TensorFlow 算法框架/工具
成功解决AttributeError: module ‘tensorflow‘ has no attribute ‘get_variable‘
成功解决AttributeError: module ‘tensorflow‘ has no attribute ‘get_variable‘
|
TensorFlow 算法框架/工具
成功解决AttributeError: module tensorflow has no attribute lite
成功解决AttributeError: module tensorflow has no attribute lite

热门文章

最新文章

下一篇
无影云桌面