深度学习中的激活函数大全

    科技2025-04-01  20

    深度学习中的激活函数大全

    Explanation of 3 common activation functions on Deep learning by usability.

    通过可用性说明有关深度学习的3种常见激活功能。

    为什么激活功能如此重要? (Why Activation Function so Important?)

    We can imagine activation Function is a thing that firing our brain (in this case neuron) to think. Maybe that illustration makes you more confuse :P

    我们可以想象激活功能是激发我们的大脑(在本例中为神经元)思考的事物。 也许那个插图让您更加困惑:P

    Anyway.. Without activation Function every calculation in each layer doesn’t have a meaning. Why? because the calculation is linear, which is input value has the same value with output value, implicitly. Activation function makes this is not(n) linear anymore.

    无论如何..如果没有激活功能,则每一层中的每个计算都没有意义。 为什么? 因为计算是线性的,即输入值与输出值的值隐式相同。 激活函数使它不再是线性的。

    乙状结肠 (Sigmoid)

    Sigmoid function is used together with binary_crossentropy for loss function. And we used this on final or output Layer.

    Sigmoid函数与binary_crossentropy一起用于损失函数。 我们在最终层或输出层上使用了它。

    As we can see on the image above, Sigmoid will produce value between 0 and 1. If the (x) value is negatif, so the return (y) will be near to 0. If positif will be near to 1. This behavior makes Sigmoid better use for model with 2 labels.

    如上图所示,Sigmoid将产生介于0和1之间的值。如果(x)值是negatif,则返回值(y)将接近0。如果positif将接近1。乙状结肠最好用于带有2个标签的模型。

    model.add(Dense(1))model.add(Activation('sigmoid'))model.compile(loss='binary_crossentropy', optimizer=tf.keras.optimizers.Adam(learning_rate=0.0001), metrics=['accuracy'])

    Better use Sigmoid when your model consists of 2 labels. So that can produce 1 output, which is 0 or 1.

    当模型由2个标签组成时,最好使用Sigmoid。 这样就可以产生1个输出,即0或1。

    软最大 (Softmax)

    Usually used for model that consists of more than 2 labels. And produce the same number as the size of labels. This Activation function for categorical type. That’s why it’s common using softmax with categorical_crossentropy for loss function. And we used this on final or output Layer.

    通常用于包含两个以上标签的模型。 并产生与标签大小相同的数字。 此激活函数用于分类类型。 这就是为什么将softmax与categorical_crossentropy一起用于损失函数的原因。 我们在最终层或输出层上使用了它。

    model.add(Dense(4))model.add(Activation('softmax'))model.compile(optimizer='adam',loss='categorical_crossentropy', metrics=['accuracy'])

    We call this probability activation function. Because let’s say we have these values [2.0, 1.0, 0.1] then those values will be convert to probability values[0.7, 0.2, 0.1]. If we sum the probabilities then the result must be 1.

    我们称这个概率激活函数。 因为假设我们有这些值[2.0,1.0,0.1],那么这些值将被转换为概率值[0.7,0.2,0.1]。 如果我们对概率求和,则结果必须为1。

    Softmax Formula Softmax公式

    露露(Relu)

    Popular activation function on Deep Learning. Usually we used Relu on Input Layer input and hidden layer.

    深度学习中流行的激活功能。 通常我们在输入层输入和隐藏层上使用Relu。

    The result of Relu activation function is always positive. Because when the (x) value is negative, so that the (y) value will be 0. And if positive, relu never change the value.

    Relu激活功能的结果始终为正。 因为(x)值为负,所以(y)值为0。如果为正,则relu永远不会更改该值。

    So then if the result is 0 then this value never fired, this means this value never pass forward to the next layer.

    因此,如果结果为0,则永远不会触发该值,这意味着该值永远不会传递到下一层。

    Another reason why Relu is common used in hidden layer is because the calculation is so fast.

    Relu在隐藏层中普遍使用的另一个原因是因为计算速度如此之快。

    model.add(Conv2D(32, (5,5)))model.add(Activation('relu'))

    翻译自: https://medium.com/@ade.sueb/usability-of-activation-function-on-deep-learning-6b7efe8aec18

    深度学习中的激活函数大全

    相关资源:四史答题软件安装包exe
    Processed: 0.009, SQL: 8