我最近在阅读的一些 Lua 源文件中经常看到这种类型的语法,这是什么意思,尤其是第二对括号一个示例, https://github.com/karpathy/char-rnn/blob中的第 8 行/master/model/LSTM.lua
local LSTM = {}
function LSTM.lstm(input_size, rnn_size, n, dropout)
dropout = dropout or 0
-- there will be 2*n+1 inputs
local inputs = {}
table.insert(inputs, nn.Identity()()) -- line 8
-- ...
https://github.com/torch/nn/blob/master/Identity.lua的源代码nn.Identity
********** 更新 **************
()() 模式在火炬库 'nn' 中被大量使用。第一对括号创建容器/节点的对象,第二对括号引用依赖节点。
例如,y = nn.Linear(2,4)(x) 表示 x 连接到 y,从 1*2 到 1*4 的变换是线性的。我只是了解用法,它的接线方式似乎可以通过以下答案之一来回答。
无论如何,接口的使用在下面有很好的记录。 https://github.com/torch/nngraph/blob/master/README.md