tensorflow:AttributeError:'module'对象没有属性'mul'

Dan*_*Dan 68 python tensorflow

我已经使用了tensorflow一天,但是有一些麻烦,当我导入tensorflow时,会出现AttributeError:'module'对象没有属性'XXXXXX'

环境

我使用ubuntu14.04,python2.7,CUDA工具包8.0和CuDNN v5.我的六个和protobuf的版本是:名称:六个版本:1.10.0位置:/usr/local/lib/python2.7/dist-packages需要:名称:protobuf版本:3.2.0位置:/ usr/local/lib/python2.7/dist-packages需要:six,setuptools

这是我的测试代码:

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})
Run Code Online (Sandbox Code Playgroud)

我得到这个输出:

在此输入图像描述

tensorflow安装有问题吗?还是其他任何问题?

小智 177

根据tensorflow 1.0.0发布说明,

tf.mul,tf.sub并且tf.neg不赞成使用tf.multiply,tf.subtracttf.negative.

你将需要更换tf.multf.multiply.

  • 文档说"弃用",但实际上TF刚删除它们...... (6认同)