常用激活函数
import theano
from keras import backend as K
import keras.activations as A
#
from pylab import *
x = theano.tensor.dmatrix()
softmax = theano.function([x], A.softmax(x))
softplus = theano.function([x], A.softplus(x))
relu = theano.function([x], A.relu(x))
tanh = theano.function([x], A.tanh(x))
sigmoid = theano.function([x], A.sigmoid(x))
hard_sigmoid = theano.function([x], A.hard_sigmoid(x))
linear = theano.function([x], A.linear(x))
xv = np.array([range(-20, 20)])
for i, fn in enumerate(["softmax", "softplus", "relu", "tanh", "sigmoid", "hard_sigmoid", "linear"]):
plt.subplot(3, 3, i + 1)
plt.title(fn)
plt.plot(xv[0], eval(fn)(xv)[0])
plt.show()
本文探讨了在神经网络中常用的激活函数如softmax、softplus、ReLU、tanh、sigmoid、hard_sigmoid和linear的功能及其在不同场景下的应用。
4894

被折叠的 条评论
为什么被折叠?



