在学习tensorflow的时候,照到官方的例子做,发现了一个

Traceback (most recent call last):
  File "interactive.py", line 10, in <module>
    sub = tf.sub(x,a)
AttributeError: module 'tensorflow' has no attribute 'sub'

一猜,我就估计是函数换名字了,果然,换成了subtract 这样就坑过了

# -*- coding: utf-8 -*-
import tensorflow as tf
sess = tf.InteractiveSession()

x = tf.Variable([1.0, 2.0])
a = tf.constant([3.0, 3.0])

x.initializer.run()

sub = tf.subtract(x,a)
print(sub.eval())

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
  • 2022-01-22
  • 2021-12-08
  • 2021-06-17
猜你喜欢
  • 2022-12-23
  • 2021-12-23
  • 2021-09-19
  • 2021-10-20
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
相关资源
相似解决方案