【问题标题】:Drawing network in Caffe causes pydot to throw End of Line errors在 Caffe 中绘制网络导致 pydot 抛出 End of Line 错误
【发布时间】:2015-05-17 07:42:34
【问题描述】:

所以我刚刚从 master 分支中提取了最新版本的 Caffe,并完成了所有初始化步骤。作为一个快速测试,我试图运行提供的python/draw_net.py 脚本,以可视化 MNIST Autoencoder 示例网络。 在执行以下命令时:

./python/draw_net.py examples/mnist/mnist_autoencoder.prototxt trial_viz.png

Pydot 抱怨,并抛出以下错误:

Drawing net to trial_viz.png
Traceback (most recent call last):
  File "./python/draw_net.py", line 44, in <module>
    main()
  File "./python/draw_net.py", line 40, in main
    caffe.draw.draw_net_to_file(net, args.output_image_file, args.rankdir)
  File "/home/username/3rdparty/caffe/python/caffe/draw.py", line 165, in draw_net_to_file
    fid.write(draw_net(caffe_net, rankdir, ext))
  File "/home/username/3rdparty/caffe/python/caffe/draw.py", line 156, in draw_net
    return get_pydot_graph(caffe_net, rankdir).create(format=ext)
  File "/usr/lib/pymodules/python2.7/pydot.py", line 1796, in create
    status, stderr_output) )
pydot.InvocationException: Program terminated with status: 1. stderr follows: Warning: /tmp/tmpjqPQBC:5: string ran past end of line
Error: /tmp/tmpjqPQBC:6: syntax error near line 6
context:  >>> ( <<< Sigmoid)" [shape=record, style=filled, fillcolor="#6495ED"];
Warning: /tmp/tmpjqPQBC:6: ambiguous "6495ED" splits into two names: "6495" and "ED"
Warning: /tmp/tmpjqPQBC:6: string ran past end of line
Warning: /tmp/tmpjqPQBC:9: string ran past end of line
Warning: /tmp/tmpjqPQBC:10: string ran past end of line
Warning: /tmp/tmpjqPQBC:12: string ran past end of line
Warning: /tmp/tmpjqPQBC:13: ambiguous "6495ED" splits into two names: "6495" and "ED"
Warning: /tmp/tmpjqPQBC:13: string ran past end of line
Warning: /tmp/tmpjqPQBC:14: string ran past end of line
Warning: /tmp/tmpjqPQBC:15: string ran past end of line
Warning: /tmp/tmpjqPQBC:17: string ran past end of line
Warning: /tmp/tmpjqPQBC:18: ambiguous "6495ED" splits into two names: "6495" and "ED"

我看到更多类似上面显示的Warning 消息,并且我的错误日志变得太大,所以我没有发布整个日志。 This post,似乎看到和我一样的错误,所以我尝试复制他们的解决方案,并将draw.py 中的get_pydot_graph() 方法中的所有字符串更改为原始字符串。但这似乎不起作用。

关于如何解决这个问题的任何建议?

谢谢!! :)

【问题讨论】:

    标签: python ubuntu-12.04 pydot caffe


    【解决方案1】:

    我认为关键在于 determine_node_label_by_layertype 函数。这是一段代码,应该看起来像这样(或者至少在我当前版本的存储库中是这样):

    def determine_node_label_by_layertype(layer, layertype, rankdir):
    """Define node label based on layer type
    """
    
        if rankdir in ('TB', 'BT'):
            # If graph orientation is vertical, horizontal space is free and
            # vertical space is not; separate words with spaces
            separator = ' '
        else:
            # If graph orientation is horizontal, vertical space is free and
            # horizontal space is not; separate words with newlines
            separator = '\n'
    

    separater = '\n' 替换为separater = r"\n",它似乎对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-17
      • 1970-01-01
      • 1970-01-01
      • 2018-05-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-13
      • 2017-11-20
      相关资源
      最近更新 更多