神经网络的传递函数

Transfer function of neural network

我使用 torch7 构建了一个 3 隐藏层神经网络来处理分类问题 (3 类)。但是我对使用什么传递函数以及如何使用它们感到困惑。下面是我的网络结构:

net:add(nn.Linear(inputs, hid_1))
net:add(nn.Tanh())
net:add(nn.Linear(hid_1, hid_2))
net:add(nn.Tanh())
net:add(nn.Linear(hid_2, hid_3))
net:add(nn.Tanh())
net:add(nn.Linear(hid_3, outputs))
net:add(nn.LogSoftMax())

criterion = nn.ClassNLLCriterion()

如上所述,我使用了所有的 Tanh() 传递函数,对吗?我可以使用其他传输功能(如 Sigmoid().. )吗?我是否必须在每一层之间插入传递函数?

非常感谢。

As above, I used all Tanh() transfer functions, is that correct?

是正确的,使用任何其他传递函数也是正确的。

Can I use other transfer fucntion (like Sigmoid().. )?

是的,你可以使用任何传递函数,每个传递函数都有自己的属性,用 SO 形式表达这些函数很长,但是现在你可能会发现 ReLU 是最常用的传递函数之一,尤其是在更深层次的网络。

And do I have to insert transfer function between each layer?

是的,如果你不这样做——从数学上讲,你的层会崩溃(至少在最终行为的意义上,连续的线性层表现为一个单一的线性层——训练可能会有所不同)。