The following two issues were encountered in TensorFlow Chinese document Learning TensorFlow in TensorFlow official documents and Geek College:
1) attributeerror:module ' TensorFlow ' has no attribute ' sub '
# Enter an interactive tensorflow session Import == tf. Variable ([1.0,2.0= tf.constant ([3.0,3.0])# initializes ' x ' with the Run () method of the initializer Initalizer op X.initializer.run () # Add a Subtraction sub op, subtract ' a ' from ' X ', run minus op, output sub = tf.sub (x,a)print(Sub.eval () ) # task complete, close reply Sess.close ()
Executive Times Error:
Traceback (most recent): " c:/pythonproj/tensorflow/first_tensorflow.py " in <module> ='tensorflow ' Sub'
After the pycharm in the TF. Auto-echo information, I found that this sub function has been replaced by subtract, replaced by Tf.subtract (x,a), OK, all smooth!
2) Attributeerror:module ' TensorFlow ' has no attribute ' mul '
INPUT1 = tf.constant (3.0= tf.constant (2.0= tf.constant (5.0== Tf.mul (INPUT1, intermed) with TF. Session () as sess: = Sess.run ([mul,intermed]) print(Result)
The error message is:
Traceback (most recent): " c:/pythonproj/tensorflow/first_tensorflow.py " in <module> ='tensorflow ' Mul'
In the same vein, after the observation of the pycharm in TF, I found that the Tf.mul function has been replaced by tf.multiply, modified, ok!
The functions in sub and mul in the official TensorFlow document have been renamed in the API