使用itorch时无法加载Lib graphviz

问题描述 投票:0回答:1

我正在按照火炬队提供的教程学习火炬。当我按照'NNGraph Tutorial'提供的方式键入下面的行时,出乎意料的发生了:

-- it is common style to mark inputs with identity nodes for clarity.
input = nn.Identity()()

-- each hidden layer is achieved by connecting the previous one
-- here we define a single hidden layer network
h1 = nn.Tanh()(nn.Linear(20, 10)(input))
output = nn.Linear(10, 1)(h1)
mlp = nn.gModule({input}, {output})

x = torch.rand(20)
dx = torch.rand(1)
mlp:updateOutput(x)
mlp:updateGradInput(x, dx)
mlp:accGradParameters(x, dx)

-- draw graph (the forward graph, '.fg')
-- this will produce an SVG in the runtime directory
graph.dot(mlp.fg, 'MLP', 'MLP')
itorch.image('MLP.svg')

错误信息:

...s/noahcao/torch/install/share/lua/5.2/graph/graphviz.lua:157:   graphviz library could not be loaded.
stack traceback:
/Users/noahcao/torch/install/share/lua/5.2/itorch/main.lua:167: in function </Users/noahcao/torch/install/share/lua/5.2/itorch/main.lua:160>
[C]: in function 'error'
...s/noahcao/torch/install/share/lua/5.2/graph/graphviz.lua:157: in function 'graphvizFile'
...s/noahcao/torch/install/share/lua/5.2/graph/graphviz.lua:197: in function 'dot'
[string "-- it is common style to mark inputs with ide..."]:18: in main chunk
[C]: in function 'xpcall'
/Users/noahcao/torch/install/share/lua/5.2/itorch/main.lua:210: in function </Users/noahcao/torch/install/share/lua/5.2/itorch/main.lua:174>
(...tail calls...)
/Users/noahcao/torch/install/share/lua/5.2/lzmq/poller.lua:75: in function 'poll'
...s/noahcao/torch/install/share/lua/5.2/lzmq/impl/loop.lua:307: in function 'poll'
...s/noahcao/torch/install/share/lua/5.2/lzmq/impl/loop.lua:325: in function 'sleep_ex'
...s/noahcao/torch/install/share/lua/5.2/lzmq/impl/loop.lua:370: in function 'start'
/Users/noahcao/torch/install/share/lua/5.2/itorch/main.lua:389: in main chunk
[C]: in function 'require'
(command line):1: in main chunk
[C]: in ?

但是我检查了graphviz.lua文件,看起来没问题。我无法理解这些信息想告诉我什么。

lua graphviz torch
1个回答
2
投票

我也面临同样的问题。这解决了我的问题:

# Mac users
brew install graphviz

# Debian/Ubuntu users
sudo apt-get install graphviz -y

希望这可以帮助某人。

请查看此link以获取Torch的Graph包。

© www.soinside.com 2019 - 2024. All rights reserved.