tensorflow之【AttributeError: module 'tensorflow' has no attribute 'mul'】

た 入场券 2022-05-18 03:56 252阅读 0赞

1、注意:

我是用的tensorflow版本:V1.9

2、运行下面的代码:

  1. #!/usr/bin/python3
  2. import tensorflow as tf
  3. input1 = tf.constant(3.0)
  4. input2 = tf.constant(2.0)
  5. input3 = tf.constant(5.0)
  6. intermed = tf.add(input2, input3)
  7. mul1 = tf.mul(input1, intermed)
  8. with tf.Session() as sess:
  9. result = sess.run([mul1, intermed])
  10. print(result)

终端运行发现:

  1. Traceback (most recent call last):
  2. File "hdemo.py", line 54, in <module>
  3. mul1 = tf.mul(input1, intermed)
  4. AttributeError: module 'tensorflow' has no attribute 'mul'

在线查阅文档得知,旧版 的 mul 已经 在V1.9版本中替换成了 multiply 。

发表评论

表情:
评论列表 (有 0 条评论,252人围观)

还没有评论,来说两句吧...

相关阅读