I have used tensorflow for ONE day,but there comes some troubles,when I import tensorflow, there would be AttributeError: 'module' object has no attribute 'XXXXXX'
I use ubuntu14.04, python2.7, CUDA toolkit 8.0 and CuDNN v5. And versions of my six and protobuf are: Name: six Version: 1.10.0 Location: /usr/local/lib/python2.7/dist-packages Requires: Name: protobuf Version: 3.2.0 Location: /usr/local/lib/python2.7/dist-packages Requires: six, setuptools
here is my test code:
import tensorflow as tf
a = tf.placeholder(tf.int16)
b = tf.placeholder(tf.int16)
add = tf.add(a, b)
mul = tf.mul(a, b)
with tf.Session() as sess:
# Run every operation with variable input
print "Addition with variables: %i" % sess.run(add, feed_dict={a: 2, b: 3})
print "Multiplication with variables: %i" % sess.run(mul, feed_dict={a: 2, b: 3})
I get this output:
Is there any problem with the tensorflow installation? or any other problems?
According to the tensorflow 1.0.0 release notes,
tf.mul
,tf.sub
andtf.neg
are deprecated in favor oftf.multiply
,tf.subtract
andtf.negative
.
You'll need to replace tf.mul
with tf.multiply
.
This operation was previously available in 0.x versions. With the release of TF 1.0 they introduced breaking changes to the API. In addition to
tf.mul
,tf.sub
andtf.neg
are deprecated in favor oftf.multiply
,tf.subtract
andtf.negative
many other functions were renamed and changed with the following justification:
Several python API calls have been changed to resemble NumPy more closely.
So a lot of the scripts that you already found on the web or from the books will not work. Good thing is that majority of them can be fixed with their migration script. It can be run with tf_upgrade.py --infile foo.py --outfile foo-upgraded.py
. It will not be able to solve everything (limitations are listed here), but will save you a lot of work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With