tensorflow - tensorflow 急切执行在运行时发生变化
问题描述
我正在使用 tensor2tensor (1.9.0) 和 tensorflow 1.9。当我尝试tf.enable_eager_execution()
在 t2t-decoder 中启用急切执行时,它工作得很好。但是,当程序在 tensor2tensor 的 python 代码中中断时,我发现急切执行已被禁用。试图在 t2t 框架内寻找任何可能禁用它的东西,但我找不到任何可能做到这一点的东西。
版本:t2t 1.9.0 tensorflow (cpu) 1.9.0 python 3.6 ubuntu 18.04
解决方案
我正在使用 python 3。我必须将 tensorflow 和 tf.enable_eager_execution 放在脚本的顶部
import tensorflow as tf
tf.enable_eager_execution()
you may have to shutdown the kernal and jupyter notes than reopen them.
a=tf.Variable([1,2])
a.assign([5, 6])
print(a.numpy())
输出:
[5,6]
推荐阅读
- python - Python:TypeError:__init__() 缺少 1 个必需的位置参数:'privileges' - 如何调试代码?
- java - 支持黄瓜和协程的猎犬吗?
- php - 我需要清理从文件中获取的 php 代码吗?
- c - 无法使用 wrap 代理 C 函数
- reactjs - 对幻灯片中的不同组件应用不同的效果。刷卡器 | 离子
- python - 删除列表中的重复项
- swift - 快速协助 if 语句
- c# - CancellationToken.Register 的替代方法用于异步方法/在 BackgroundService 关闭时
- reactjs - 如何使用原生 SQL 生成元数据 // 如何在没有列名的情况下检索生成的数据?
- node.js - 将大量数据切割成从端点(API)返回的块,以减少来自反应客户端的 axios 延迟