当前位置: 首页 > news >正文

【DL-TensorFlow遇错】TensorFlow中遇错合集

TensorFlow中遇错合集

  • 一、`AttributeError: module 'tensorflow' has no attribute 'placeholder'`
  • 二、`RuntimeError: tf.placeholder() is not compatible with eager execution.`

一、AttributeError: module 'tensorflow' has no attribute 'placeholder'

错误原因

  • tensorflow版本问题:当前tensorflow版本为2.X,而tensorflow 2.0版本去掉了placeholder。tensorflow 1.*版本才有placeholder。

解决方案

  • “向后兼容”。这种做法可以在新版本的TensorFlow中仍然使用旧的API,确保旧代码的兼容性。

具体实现

  • 修改import tensorflow as tfimport tensorflow._api.v2.compat.v1 as tf

二、RuntimeError: tf.placeholder() is not compatible with eager execution.

错误原因

  • tf.placeholder()意味着被提供给会话,该会话在运行时从feed dict接收值并执行所需的操作。(也就是默认为急切运行,我们爆出这个错误说明不需要急切运行

解决方案
方式一:

  • tf.placeholder()被调用前添加tf.compat.v1.disable_eager_execution()

方式二:

import tensorflow._api.v2.compat.v1 as tf
tf.compat.v1.disable_eager_execution()
http://www.lryc.cn/news/258777.html

相关文章:

  • pymysql代替mysqlclient,解决mysqlclient因版本不兼容无法安装成功而无法连接mysql的问题
  • uni-app 设置当前page界面进入直接变为横屏模式
  • Mysql的多表联合查询
  • Linux上使用Python的requests库进行HTTP请求
  • 图像处理领域的应用
  • MySQL笔记-第18章_MySQL8其它新特性
  • C语言—每日选择题—Day46
  • flex布局,换行的元素上下设置间距
  • 【智能家居】八、监控摄像采集、人脸识别比对进行开门功能点
  • golang的文件操作
  • 数据库版本管理框架-Flyway(从入门到精通)
  • 外网访问内网服务器使用教程
  • C# Dictionary 利用 ContainsValue 查询指定值是否已经存在
  • 招不到人?用C语言采集系统批量采集简历
  • HXDSP2441-Demo板
  • 静态路由的原理和配置
  • Ubuntu20.04降低linux版本到5.4.0-26-generic
  • C++ 类型萃取
  • 【JVM从入门到实战】(四)类的生命周期
  • 2023年度美食关键词-葱油花卷
  • 「Verilog学习笔记」简易秒表
  • 《每天一个Linux命令》 -- (12) file命令
  • 如何使用ArcGIS Pro制作类似CAD的尺寸注记
  • Go语言bufio包的使用
  • 计算机网络之IP篇
  • Java中JDK类库常用的6种设计模式
  • C++ 用法全面剖析
  • 数据库结构
  • 什么是HTML以及超链接,特殊符号转义的简单使用
  • 汽车销售技巧培训应该学习哪些内容