Python – tensorflow:AttributeError: ‘module’ object has no attribute ‘mul’

pythontensorflow

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'

Environment

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:

enter image description here

Is there any problem with the tensorflow installation? or any other problems?

Best Solution

According to the tensorflow 1.0.0 release notes,

tf.mul, tf.sub and tf.neg are deprecated in favor of tf.multiply, tf.subtract and tf.negative.

You'll need to replace tf.mul with tf.multiply.

Related Question