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
tonp.floating
is deprecated. In future, it will be treated asnp.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'
早在version 1.5中,立即执行仍然在提供的包中,因此您需要显式地导入它;正确的用法是:
另外,请记住:
(来自Github page)
版本1.7是第一个提供命令
tf.enable_eager_execution()
的版本,也就是说,急切执行被移出contrib
(参见v1.7 changes)。在相关问题 更多 >
编程相关推荐