无效的格式字符串Tensorboard

时间:2019-02-21 18:42:56

标签: python tensorflow tensorboard

我有以下代码:

import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
sess = tf.Session()
a = tf.placeholder(tf.float64, name="A")
b = tf.placeholder(tf.float64, name="B")
add = tf.add(a, b, name='Addition')
result = sess.run(add, {a:32, b:44})
print(result)
file = tf.summary.FileWriter('./logs', sess.graph)
sess.close()

只是为了生成运行Tensorboard的示例。 当我运行tensorboard --logdir=./logs生成图形时,错误是:

TensorBoard 1.13.0a20190211 at http://LAPTOP-Lin:6006 (Press CTRL+C to quit)
Traceback (most recent call last):
  File "c:\python3.6.4\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python3.6.4\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python3.6.4\Scripts\tensorboard.exe\__main__.py", line 9, in <module>
  File "c:\python3.6.4\lib\site-packages\tensorboard\main.py", line 62, in run_main
    app.run(tensorboard.main, flags_parser=tensorboard.configure)
  File "c:\python3.6.4\lib\site-packages\absl\app.py", line 300, in run
    _run_main(main, args)
  File "c:\python3.6.4\lib\site-packages\absl\app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "c:\python3.6.4\lib\site-packages\tensorboard\program.py", line 226, in main
    self._register_info(server)
  File "c:\python3.6.4\lib\site-packages\tensorboard\program.py", line 272, in _register_info
    manager.write_info_file(info)
  File "c:\python3.6.4\lib\site-packages\tensorboard\manager.py", line 268, in write_info_file
    payload = "%s\n" % _info_to_string(tensorboard_info)
  File "c:\python3.6.4\lib\site-packages\tensorboard\manager.py", line 128, in _info_to_string
    for k in _TENSORBOARD_INFO_FIELDS
  File "c:\python3.6.4\lib\site-packages\tensorboard\manager.py", line 128, in <dictcomp>
    for k in _TENSORBOARD_INFO_FIELDS
  File "c:\python3.6.4\lib\site-packages\tensorboard\manager.py", line 50, in <lambda>
    serialize=lambda dt: int(dt.strftime("%s")),
ValueError: Invalid format string

那么这里出了什么问题?我在Windows 10上

2 个答案:

答案 0 :(得分:13)

这是Tensorboard的一个小错误,只需在第50行中打开此文件“ c:\ python3.6.4 \ lib \ site-packages \ tensorboard \ manager.py”     serialize = lambda dt:int(dt.strftime(“%s”)),

然后将strftime(“%s”)更改为strftime(“%S”)==>仅将%s更改为%S

答案 1 :(得分:0)

更改到tensorboard / manager.py将行号50从serialize = lambda dt:int(dt.strftime(“%s”))更改为data Map k a = Bin (Map k a) a (Map k a) | Nil