【问题标题】:Tensorboard Graph Visualiyation Error using Python 3使用 Python 3 的 Tensorboard 图形可视化错误
【发布时间】:2016-03-28 18:26:28
【问题描述】:

我清除了 tensorboard.py 和 tensorboard_handler.py 文件中 python 2to3 的差异,但 Tensorboard 仍然有 Visualization 错误。

浏览器端错误:

图形可视化失败:错误:解析图形定义失败

服务器端错误日志为:

Exception happened during processing of request from ('127.0.0.1', 52783)

Traceback (most recent call last):

  File "/usr/lib/python3.4/socketserver.py", line 617, in process_request_thread

    self.finish_request(request, client_address)

  File "/usr/lib/python3.4/socketserver.py", line 344, in finish_request

    self.RequestHandlerClass(request, client_address, self)

  File "/usr/lib/python3.4/site-
packages/tensorflow/tensorboard/tensorboard_handler.py", line 85, in __ init __

    http.server.BaseHTTPRequestHandler.__init__(self,*args)

  File "/usr/lib/python3.4/socketserver.py", line 673, in __ init __

    self.handle()

  File "/usr/lib/python3.4/http/server.py", line 398, in handle

    self.handle_one_request()

  File "/usr/lib/python3.4/http/server.py", line 386, in handle_one_request

    method()

  File "/usr/lib/python3.4/site-
packages/tensorflow/tensorboard/tensorboard_handler.py", line 389, in do_GET

    handlers[clean_path](query_params)

  File "/usr/lib/python3.4/site-
packages/tensorflow/tensorboard/tensorboard_handler.py", line 217, in 
_serve_graph

    self._send_gzip_response(graph_pbtxt, 'text/plain')

  File "/usr/lib/python3.4/site-
packages/tensorflow/tensorboard/tensorboard_handler.py", line 135, in 
_send_gzip_response

    f = gzip.GzipFile(fileobj=out, mode='w')

  File "/usr/lib/python3.4/gzip.py", line 220, in __ init __

    self._write_gzip_header()

  File "/usr/lib/python3.4/gzip.py", line 252, in _write_gzip_header

    self.fileobj.write(b'\037\213')             # magic header

TypeError: string argument expected, got 'bytes'

【问题讨论】:

  • 投票结束,因为不清楚您的要求。

标签: python python-3.x tensorflow tensorboard


【解决方案1】:

tensorboard_handler.py 使用StringIO,但随后将字节传递给它。使用 Python 3 时,它可能应该改用 BytesIO(这是 Python 3 中的新功能)。这个问题是相关的:StringIO in python3

很遗憾,Tensorboard 尚不支持 python 3,但如果您碰巧解决了这个问题,请发送拉取请求。

【讨论】:

  • 运行 2to3 并用 BytesIO 替换 StringIO 确实解决了 Python 3 的问题。我已在本地修复它,但需要确保代码在发送拉取请求之前在 Python 2 和 3 中运行。
猜你喜欢
  • 2018-04-13
  • 2021-02-24
  • 1970-01-01
  • 2020-01-22
  • 2016-02-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-02-03
相关资源
最近更新 更多