如何剖析Tensorflow

时间:2019-06-25 11:11:25

标签: python tensorflow profiling

这说明了如何配置Tensorflow https://jsfiddle.net/ov4nx7ad/

但是,当我尝试调整它以分析model.fit时,如下所示:

with tf.Session() as sess:
    sess.run(model.fit(x_train, y_train,
                        epochs=numberOfEpochs,
                        batch_size=128), options=run_options, run_metadata=run_metadata)

    # Profiling output
    trace = timeline.Timeline(step_stats=run_metadata.step_stats)
    with open('timeline.ctf.json', 'w') as f:
        f.write(trace.generate_chrome_trace_format())

我收到以下错误:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\tensorflow\python\client\session.py", line 303, in __init__
    fetch, allow_tensor=True, allow_operation=True))
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\tensorflow\python\framework\ops.py", line 3796, in as_graph_element
    return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\tensorflow\python\framework\ops.py", line 3885, in _as_graph_element_locked
    (type(obj).__name__, types_str))
TypeError: Can not convert a History into a Tensor or Operation.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:/dev/sources/trunk/NN/Predictor/Classifier/Classifier.py", line 47, in <module>
    batch_size=128), options=run_options, run_metadata=run_metadata)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\tensorflow\python\client\session.py", line 950, in run
    run_metadata_ptr)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\tensorflow\python\client\session.py", line 1158, in _run
    self._graph, fetches, feed_dict_tensor, feed_handles=feed_handles)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\tensorflow\python\client\session.py", line 474, in __init__
    self._fetch_mapper = _FetchMapper.for_fetch(fetches)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\tensorflow\python\client\session.py", line 274, in for_fetch
    return _ElementFetchMapper(fetches, contraction_fn)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\tensorflow\python\client\session.py", line 307, in __init__
    (fetch, type(fetch), str(e)))

TypeError: Fetch argument <keras.callbacks.History object at 0x000001B07F94E7B8> has invalid type <class 'keras.callbacks.History'>, must be a string or Tensor. (Can not convert a History into a Tensor or Operation.)

知道我在做什么错吗?

0 个答案:

没有答案