无法在windows7 machin上的Tensorflow 1.5中使用紧急执行

2024-05-03 05:23:53 发布

您现在位置:Python中文网/ 问答频道 /正文

问题

cant use eager execution in tensorflow version 1.5

编码

from __future__ import absolute_import, division, print_function

import tensorflow as tf
from tensorflow.python.client import timeline

tf.enable_eager_execution()

x = tf.random_normal([0,10000])
y= tf.random_normal([10000,1000])

res = tf.matmul(x, y)

# Run the graph with full trace option
with tf.Session() as sess:
    run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
    run_metadata = tf.RunMetadata()
    sess.run(res, options=run_options, run_metadata=run_metadata)

    # Create the Timeline object, and write it to a json
    tl = timeline.Timeline(run_metadata.step_stats)
    ctf = tl.generate_chrome_trace_format()
    with open('timeline.json', 'w') as f:
        f.write(ctf)

堆栈跟踪

C:\ProgramData\Anaconda3\lib\site-packages\h5py__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Traceback (most recent call last): File "D:/Users/hello/PycharmProjects/crimeBuster/main.py", line 6, in tf.enable_eager_execution() AttributeError: module 'tensorflow' has no attribute 'enable_eager_execution'

版本

^{pr2}$

Tags: therunfromimportenabletftensorflowas
1条回答
网友
1楼 · 发布于 2024-05-03 05:23:53

早在version 1.5中,立即执行仍然在提供的包中,因此您需要显式地导入它;正确的用法是:

import tensorflow as tf
import tensorflow.contrib.eager as tfe
tfe.enable_eager_execution()

另外,请记住:

For eager execution, we recommend using TensorFlow version 1.8 or newer.

(来自Github page

版本1.7是第一个提供命令tf.enable_eager_execution()的版本,也就是说,急切执行被移出contrib(参见v1.7 changes)。在

相关问题 更多 >