Erlang spawn 过程错误(人工神经网络)
Erlang spawn process error (artificial neural network)
嗨,Erlang 新手在这里尝试按照 this tutorial from Wil Chung. The code is exactly as in his github repo.
实现基本的 ANN(人工神经网络)
运行这个:
1> ann_test:run().
导致一堆(准确地说是五个)错误,如下所示:
=ERROR REPORT==== 18-Feb-2015::07:11:49
=== Error in process <0.60.0> with exit value: {undef,[{ann,perceptron,[[],[],[]],[]}]}
=ERROR REPORT==== 18-Feb-2015::07:11:49
=== Error in process <0.61.0> with exit value: {undef,[{ann,perceptron,[[],[],[]],[]}]}
以某种方式在 ann_test.erl:
中生成进程
X1_pid = spawn(ann, perceptron, [[],[],[]]),
引起了麻烦,但我不确定如何追踪它。尝试使用 redbug 将问题指向 ann_test:运行 和 ann:perceptron 但它没有显示任何事物。还尝试将 process_flag(trap_exit, true) 添加到 运行() 但什么也没有。还尝试添加 -compile(export_all) 以防万一。
谁能指出我正确的方向?非常感谢。
这段代码有问题。此错误意味着没有与参数匹配的导出函数 ann:perceptron/3
。只有 ann:perceptron/4
。它在 ann_test:setup/0
中被正确使用,因此要修复它,只需添加另一个空列表:
run() ->
ann_graph:start(),
X1_pid = spawn(ann, perceptron, [[],[],[]]),
X2_pid = spawn(ann, perceptron, [[],[],[]]),
H1_pid = spawn(ann, perceptron, [[],[],[]]),
H2_pid = spawn(ann, perceptron, [[],[],[]]),
O_pid = spawn(ann, perceptron, [[],[],[]]),
更改为:
run() ->
ann_graph:start(),
X1_pid = spawn(ann, perceptron, [[],[],[],[]]),
X2_pid = spawn(ann, perceptron, [[],[],[],[]]),
H1_pid = spawn(ann, perceptron, [[],[],[],[]]),
H2_pid = spawn(ann, perceptron, [[],[],[],[]]),
O_pid = spawn(ann, perceptron, [[],[],[],[]]),
请注意,此代码在执行后不会清除,并且在同一会话中最终重新执行后会出现错误。要终止已注册的进程 ann_grapher
,您可以使用 exit(whereis(ann_grapher), kill).
您可以这样阅读此错误消息 {undef,[{ann,perceptron,[[],[],[]],[]}]}
:
- 没有函数(
undef
)
- 在模块
ann
中
- 叫
perceptron
- 接受三个参数,都是空列表
[[], [], []]
这是正确的,因为只有一个定义,它有 4 个参数,而不是三个。在 ann_test:setup
中,perceptron
生成了四个空列表。你可以试试。
换句话说,错误消息中的元组具有结构 {Module, Function, ListOfArguments, NotSureWhatThatIs}
嗨,Erlang 新手在这里尝试按照 this tutorial from Wil Chung. The code is exactly as in his github repo.
实现基本的 ANN(人工神经网络)运行这个:
1> ann_test:run().
导致一堆(准确地说是五个)错误,如下所示:
=ERROR REPORT==== 18-Feb-2015::07:11:49 === Error in process <0.60.0> with exit value: {undef,[{ann,perceptron,[[],[],[]],[]}]}
=ERROR REPORT==== 18-Feb-2015::07:11:49 === Error in process <0.61.0> with exit value: {undef,[{ann,perceptron,[[],[],[]],[]}]}
以某种方式在 ann_test.erl:
中生成进程X1_pid = spawn(ann, perceptron, [[],[],[]]),
引起了麻烦,但我不确定如何追踪它。尝试使用 redbug 将问题指向 ann_test:运行 和 ann:perceptron 但它没有显示任何事物。还尝试将 process_flag(trap_exit, true) 添加到 运行() 但什么也没有。还尝试添加 -compile(export_all) 以防万一。
谁能指出我正确的方向?非常感谢。
这段代码有问题。此错误意味着没有与参数匹配的导出函数 ann:perceptron/3
。只有 ann:perceptron/4
。它在 ann_test:setup/0
中被正确使用,因此要修复它,只需添加另一个空列表:
run() ->
ann_graph:start(),
X1_pid = spawn(ann, perceptron, [[],[],[]]),
X2_pid = spawn(ann, perceptron, [[],[],[]]),
H1_pid = spawn(ann, perceptron, [[],[],[]]),
H2_pid = spawn(ann, perceptron, [[],[],[]]),
O_pid = spawn(ann, perceptron, [[],[],[]]),
更改为:
run() ->
ann_graph:start(),
X1_pid = spawn(ann, perceptron, [[],[],[],[]]),
X2_pid = spawn(ann, perceptron, [[],[],[],[]]),
H1_pid = spawn(ann, perceptron, [[],[],[],[]]),
H2_pid = spawn(ann, perceptron, [[],[],[],[]]),
O_pid = spawn(ann, perceptron, [[],[],[],[]]),
请注意,此代码在执行后不会清除,并且在同一会话中最终重新执行后会出现错误。要终止已注册的进程 ann_grapher
,您可以使用 exit(whereis(ann_grapher), kill).
您可以这样阅读此错误消息 {undef,[{ann,perceptron,[[],[],[]],[]}]}
:
- 没有函数(
undef
) - 在模块
ann
中
- 叫
perceptron
- 接受三个参数,都是空列表
[[], [], []]
这是正确的,因为只有一个定义,它有 4 个参数,而不是三个。在 ann_test:setup
中,perceptron
生成了四个空列表。你可以试试。
换句话说,错误消息中的元组具有结构 {Module, Function, ListOfArguments, NotSureWhatThatIs}