Chainer:客户 sigmoid 激活函数

Chainer: custome sigmoid activation function

我想用自定义斜率参数 k 实现以下 sigmoid 函数。

y = f(x)= 1/ ( 1+exp(-1*k*x))
gradient gy = k * f(x)*(1-f(x))

我想在我的自动编码器中使用它。我如何在 Chainer 中实现它?

激活函数应该是 Chainer.FunctionNode (FunctionNode docs). An example of this is the Swish function provided by chainer library. You can observe its source here and clone it (or any other function such as tanh) 的子类,以便对其正向和反向操作声明进行必要的更改以满足您的需要。

如果 k 是常量(即超参数),F.sigmoid(k * x) 应该就可以了。

如果 k 是一个参数,应该像其他权重一样学习,你可能想像 L.PReLU 一样子类化 link,并像其他权重一样使用它links,例如L.LinearL.Convolution2D。您仍然可以像上面的简单表达式一样实现 link 的 forward 方法。