Рисование сети в Caffe заставляет pydot выдавать ошибки конца строки

Поэтому я просто вытащил последнюю версию Caffe из основной ветки и прошел все этапы инициализации. В качестве быстрого теста я попытался запустить предоставленный скрипт python/draw_net.py, чтобы визуализировать пример сети автоэнкодера MNIST. При выполнении следующей команды:

./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, подобных приведенным выше, и мой журнал ошибок становился слишком большим, поэтому я не публиковал весь журнал. Этот пост, кажется, видит ту же ошибку, что и я, поэтому Я попытался воспроизвести их решение и изменил все строки в методе get_pydot_graph() в draw.py на необработанные строки. Но это не сработало.

Любые предложения о том, как я могу решить эту проблему?

Спасибо!! :)


person yashc    schedule 14.03.2015    source источник


Ответы (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", и мне показалось, что это сработало.

person bahaugen    schedule 20.03.2015