AttributeError: module 'tensorflow' has no attribute 'sub'
官方的例子:运行之后出现以下错误
# 进入一个交互式 TensorFlow 会话.
import tensorflow as tf
sess = tf.InteractiveSession() x = tf.Variable([1.0, 2.0])
a = tf.constant([3.0, 3.0]) # 使用初始化器 initializer op 的 run() 方法初始化 'x'
x.initializer.run() # 增加一个减法 sub op, 从 'x' 减去 'a'. 运行减法 op, 输出结果
sub = tf.sub(x, a)
print sub.eval()
# ==> [-2. -1.]
Traceback (most recent call last):
File "C:\Users\lzm\Desktop\ten-1.py", line 10, in <module>
sub = tf.sub(x, a)
AttributeError: module 'tensorflow' has no attribute 'sub'
出现这个问题是因为sub函数换名字了,换成了subtract
# 进入一个交互式 TensorFlow 会话.
import tensorflow as tf
sess = tf.InteractiveSession() x = tf.Variable([1.0, 2.0])
a = tf.constant([3.0, 3.0]) # 使用初始化器 initializer op 的 run() 方法初始化 'x'
x.initializer.run() # 增加一个减法 sub op, 从 'x' 减去 'a'. 运行减法 op, 输出结果
sub = tf.subtract(x, a)
print sub.eval()
# ==> [-2. -1.]
AttributeError: module 'tensorflow' has no attribute 'sub'的更多相关文章
- AttributeError: module 'tensorflow' has no attribute 'enable_eager_execution'
Traceback (most recent call last): File "linear_regression_eager_api.py", line 15, in < ...
- AttributeError: module 'tensorflow' has no attribute 'Session'
版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/qq_33440324/article/ ...
- python3 ,AttributeError: module 'tensorflow' has no attribute 'merge_summary'
error:tensorflow有些方法属性被改了, self.summary_writer = tf.train.SummaryWriter(summary_dir)改为:summary.FileW ...
- AttributeError: module 'tensorflow' has no attribute 'set_random_seed'
anaconda3 python3.7 安装好tensorflow 后出现上面的问题,原因是安装的tensorflow版本是2.0的,所以使用以前的代码tensorflow中的函数不兼容.
- Debug 路漫漫-14:Python: AttributeError: module 'tensorflow' has no attribute 'sub'
在调试 <Neural Factorization Machines for Sparse Predictive Analytics>论文的源码(https://github.com/he ...
- Tensorflow之AttributeError: module 'tensorflow' has no attribute 'mul'
tf.mul已经在新版本中被移除,请使用 tf.multiply 代替
- 【pycharm】pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法
pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法 解决方法: 在pycharm的安装目 ...
- AttributeError: module ‘tensorflow.python.ops.nn’ has no attribute ‘leaky_relu’
#AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu' 的原因主要是版本的问题 解决方法是更新 ...
- 启动Tensorboard时发生错误:class BeholderHook(tf.estimator.SessionRunHook): AttributeError: module 'tensorflow.python.estimator.estimator_lib' has no attribute 'SessionRunHook'
报错:class BeholderHook(tf.estimator.SessionRunHook):AttributeError: module 'tensorflow.python.estimat ...
随机推荐
- Markdown编辑器的使用
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/LoveJavaYDJ/article/details/73692917 一.Markdown和edi ...
- mysql 源码 jin-yang.github.io
https://jin-yang.github.io/post/mysql-group-commit.html
- Android CrashHandler
package jason.android.utils; import android.content.Context; import android.content.pm.PackageInfo; ...
- iOS -- 原生NSStream实现socket
- (void)startSocket:(NSString *)address andPort:(int)port { CFReadStreamRef readRef; CFWriteStreamRe ...
- android -- 存储byte
public static String byteArrayToHexStr(byte[] byteArray) { if (byteArray == null){ return null; } ch ...
- sublime的tab和spaces空格切换的坑
python是严格要求对齐或者叫缩进的: 使用sublime对python进行编程时,可以使用tab或者空格,但是不能混用.特别是从外面把代码拷贝进sublime的时候,更要注意是否一致. 简单介绍一 ...
- EasyHook库系列使用教程之四钩子的启动与停止
此文的产生花费了大量时间对EasyHook进行深入了解同一时候參考了大量文档 先来简单比較一下EasyHook与Detour钩取后程序流程 Detours:钩取API函数后.产生两个地址,一个地址相应 ...
- JavaWeb页面添加隐藏版权信息
JavaWeb页面添加隐藏版权信息. 首先,我推荐一个值得玩味的版权站点,有兴趣的朋友能够去看上一看.Nazo Level 1,这个demo中我能发掘到有5个步骤,你看你能发现几层? 接下来.我来介绍 ...
- 我的Android进阶之旅------>Android关于Log的一个简单封装
android.util.Log类,能够方便地用于在编码调试过程中打印日志. 可是在公布后的产品中,假设有太多的日志打印.则会严重地影响性能. 对android.util.Log类做一个简单的封装.当 ...
- 笔记本Charge与Vcore方案
一.笔记本Vcore方案 EC管理智能电池的方案名词简介 我所知道的EC====>Battery 立錡VCORE解決方案簡介 ATX Power Supply 涡轮加速升压(turbo-boo ...