logistic 函数
2017-11-07 本文已影响0人
何狗带
1.logistic函数
logistic函数公式大概如下:
![](https://img.haomeiwen.com/i6560051/3c38e824f8b353be.png)
这个函数是一个S曲线,得到的结果在0和1之间,x的值越大,s(x)越接近1,x的值越小,s(x)越接近0,具体曲线如下:
![](https://img.haomeiwen.com/i6560051/c5def1f64b6da23e.png)
2.theano实现logistic函数
具体代码:
x = theano.tensor.dmatrix('x')
s = 1/(1 + T.exp(-x))
logistic = theano.function([x], s)
![](https://img.haomeiwen.com/i6560051/9749f7c50acf2353.png)
e的-x次方在theano中用 theano.tensor.exp(-x)表示。
函数会将对矩阵的每个参数进行计算,得到的结果以也是一个矩阵。