如何禁用 TensorFlow 的急切执行?

编程入门 行业动态 更新时间:2024-10-08 04:28:09
本文介绍了如何禁用 TensorFlow 的急切执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试学习 TensorFlow.目前,我正在使用占位符.当我尝试创建占位符时,出现错误:RuntimeError: tf.placeholder() is not compatible with Eager execution,这是有道理的,因为占位符不能立即执行.

I am trying to learn TensorFlow. Currently, I am working with placeholders. When I tried to create the placeholder, I got an error: RuntimeError: tf.placeholder() is not compatible with eager execution, which makes sense as placeholders are not executable immediately.

那么,如何关闭急切执行?

So, how do I turn eager execution off?

我从一开始就没有开启 Eager Execution,所以我不确定它是怎么发生的.有没有与 tf.disable_eager_execution() 相对的?

I have never turned eager execution on in the first place, so I am not sure how it happened. Is there an opposite to tf.disable_eager_execution()?

推荐答案

假设您使用的是 Tensorflow 2.0 预览版,它默认启用了 Eager Execution.v1 API 中有一个 disable_eager_execution(),你可以把它放在你的代码前面,比如:

Assume you are using Tensorflow 2.0 preview release which has eager execution enabled by default. There is a disable_eager_execution() in v1 API, which you can put in the front of your code like:

import tensorflow as tf

tfpat.v1.disable_eager_execution()

另一方面,如果您没有使用 2.0 预览版,请检查您是否不小心在某处启用了 Eager Execution.

On the other hand, if you are not using 2.0 preview, please check if you accidentally enabled eager execution somewhere.

这篇关于如何禁用 TensorFlow 的急切执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 05:32:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405389.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:急切   TensorFlow

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!