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

insert image description here

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'

Cause of the problem: The function
was canceled in version 2.0 of tensorflowtf.div()

Solution:
Use the new version 2.7.0 API

tf.math.divide()

Guess you like

Origin blog.csdn.net/m0_47256162/article/details/122500593