解决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()

目录
相关文章
AttributeError: module ‘torch.jit‘ has no attribute ‘_script_if_tracing‘
AttributeError: module ‘torch.jit‘ has no attribute ‘_script_if_tracing‘
297 0
|
PyTorch 算法框架/工具 Python
AttributeError: module ‘distutils‘ has no attribute ‘version‘解决跑pytorch代码报错
AttributeError: module ‘distutils‘ has no attribute ‘version‘解决跑pytorch代码报错
|
TensorFlow 算法框架/工具
成功解决AttributeError: module 'tensorflow.python.keras' has no attribute 'Model'
成功解决AttributeError: module 'tensorflow.python.keras' has no attribute 'Model'
AttributeError: module ‘torch.utils‘ has no attribute ‘data‘
属性错误:模块的'torch.utils'没有属性'data'
102 0
|
TensorFlow API 算法框架/工具
解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘
解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘
174 0
解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘
|
TensorFlow API 算法框架/工具
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
338 0
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
|
TensorFlow 算法框架/工具
TF版本升级问题:成功解决AttributeError: module tensorflow has no attribute mul
TF版本升级问题:成功解决AttributeError: module tensorflow has no attribute mul
TF版本升级问题:成功解决AttributeError: module tensorflow has no attribute mul
|
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 算法框架/工具
tensorflow报错:AttributeError: module ‘tensorflow._api.v2.compat.v1‘ has no attribute ‘Sessions‘,亲测有效
tensorflow报错:AttributeError: module ‘tensorflow._api.v2.compat.v1‘ has no attribute ‘Sessions‘,
1484 0
tensorflow报错:AttributeError: module ‘tensorflow._api.v2.compat.v1‘ has no attribute ‘Sessions‘,亲测有效
|
TensorFlow 算法框架/工具
成功解决AttributeError: module ‘tensorflow‘ has no attribute ‘get_variable‘
成功解决AttributeError: module ‘tensorflow‘ has no attribute ‘get_variable‘