'tensorflow' has no attribute 'sub'

在学习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())

 

    原文作者:tensorflow
    原文地址: https://www.cnblogs.com/jackluo/p/6600442.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞