'tensorflow' has no attribute 'sub'

简介: 在学习tensorflow的时候,照到官方的例子做,发现了一个 Traceback (most recent call last): File "interactive.py", line 10, in sub = tf.

在学习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
[不用回退keras版本的解决方法]AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu'
[不用回退keras版本的解决方法]AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu'
221 0
[不用回退keras版本的解决方法]AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu'
|
TensorFlow 算法框架/工具
成功解决AttributeError: module 'tensorflow.python.keras' has no attribute 'Model'
成功解决AttributeError: module 'tensorflow.python.keras' has no attribute 'Model'
|
TensorFlow 数据处理 算法框架/工具
TensorFlow 入门:Session、Variable、placeholder
TensorFlow 入门:Session、Variable、placeholder
|
TensorFlow 算法框架/工具
成功解决AttributeError: module tensorflow has no attribute lite
成功解决AttributeError: module tensorflow has no attribute lite
|
机器学习/深度学习 缓存 TensorFlow
TF:tensorflow框架中常用函数介绍—tf.Variable()和tf.get_variable()用法及其区别
TF:tensorflow框架中常用函数介绍—tf.Variable()和tf.get_variable()用法及其区别
|
TensorFlow 算法框架/工具
TensorFlow教程(3)-embedding_lookup用法
TensorFlow教程(3)-embedding_lookup用法
223 0
|
TensorFlow 算法框架/工具
成功解决AttributeError: module 'tensorflow.python.training.training' has no attribute 'SummaryWriter'
成功解决AttributeError: module 'tensorflow.python.training.training' has no attribute 'SummaryWriter'
|
TensorFlow 算法框架/工具
成功解决softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be
成功解决softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be
|
TensorFlow 算法框架/工具
成功解决WARNING:tensorflow:From :read_data_sets (from tensorflow.contrib.learn.python.learn.
成功解决WARNING:tensorflow:From :read_data_sets (from tensorflow.contrib.learn.python.learn.
|
机器学习/深度学习 TensorFlow 算法框架/工具