偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

終于把神經(jīng)網(wǎng)絡(luò)中的激活函數(shù)搞懂了!

人工智能
在神經(jīng)網(wǎng)絡(luò)中,激活函數(shù)(Activation Function)是神經(jīng)元計(jì)算的一部分,決定了一個(gè)神經(jīng)元在接收到輸入信號(hào)后的輸出。

大家好,我是小寒。

今天給大家分享神經(jīng)網(wǎng)絡(luò)中的一個(gè)重要知識(shí)點(diǎn),激活函數(shù)

在神經(jīng)網(wǎng)絡(luò)中,激活函數(shù)(Activation Function)是神經(jīng)元計(jì)算的一部分,決定了一個(gè)神經(jīng)元在接收到輸入信號(hào)后的輸出。

激活函數(shù)通過(guò)引入非線性特性,使神經(jīng)網(wǎng)絡(luò)能夠?qū)W習(xí)復(fù)雜的模式和表示。

什么是激活函數(shù)

激活函數(shù)使神經(jīng)網(wǎng)絡(luò)能夠?qū)W習(xí)和模擬輸入數(shù)據(jù)和目標(biāo)變量之間復(fù)雜的非線性關(guān)系。

通過(guò)引入非線性特性,激活函數(shù)可以幫助網(wǎng)絡(luò)處理涉及復(fù)雜函數(shù)映射的任務(wù),而這些任務(wù)僅靠線性函數(shù)無(wú)法解決。

圖片圖片

實(shí)際上,在神經(jīng)網(wǎng)絡(luò)中,神經(jīng)元的輸出是通過(guò)對(duì)輸入特征 X 及其相應(yīng)權(quán)重 W 的乘積加上偏差 b 

然后,將該線性組合傳遞到激活函數(shù) f(x),從而引入必要的非線性和輸出信號(hào)。

現(xiàn)在,這些信號(hào)成為后續(xù)層的輸入,使網(wǎng)絡(luò)能夠構(gòu)建數(shù)據(jù)的分層表示。

該機(jī)制確保 ANN 能夠從多樣化和非線性的數(shù)據(jù)分布中進(jìn)行概括和學(xué)習(xí)。

常見(jiàn)的激活函數(shù)

1.Sigmoid 激活函數(shù)

Sigmoid 函數(shù)的公式為:

圖片圖片

特點(diǎn):

  • 輸出范圍在 (0, 1) 之間。
  • 常用于二分類(lèi)問(wèn)題的輸出層。
  • 有平滑、單調(diào)遞增的特性。
  • 存在梯度消失問(wèn)題,尤其在深層網(wǎng)絡(luò)中會(huì)導(dǎo)致訓(xùn)練緩慢。

Python實(shí)現(xiàn)

import numpy as np
import matplotlib.pyplot as plt
def sigmoid(x):
 return 1 / (1 + np.exp(-x))
x = np.linspace(-10, 10, 100)
y = sigmoid(x)
plt.plot(x, y)
plt.title("Sigmoid Activation Function")
plt.show()

2.Tanh

Tanh(雙曲正切)函數(shù)的公式為:

圖片圖片

特點(diǎn):

  • 輸出范圍在 (-1, 1) 之間。
  • 比 Sigmoid 更適合深層網(wǎng)絡(luò),因?yàn)槠漭敵鼍禐?0,使得數(shù)據(jù)更容易居中。
  • 同樣存在梯度消失問(wèn)題,但比 Sigmoid 稍微好一些。

Python 實(shí)現(xiàn)

def tanh(x):
 return np.tanh(x)
y = tanh(x)
plt.plot(x, y)
plt.title("Tanh Activation Function")
plt.show()

3.ReLU

ReLU(Rectified Linear Unit)函數(shù)的公式為:

圖片圖片

特點(diǎn):

  • 輸出范圍在 [0, ∞) 之間。
  • 計(jì)算簡(jiǎn)單,收斂速度快,廣泛應(yīng)用于各種神經(jīng)網(wǎng)絡(luò)中。
  • 存在 “死亡 ReLU” 問(wèn)題,當(dāng)輸入值為負(fù)時(shí),梯度為 0,可能導(dǎo)致神經(jīng)元不會(huì)再被更新。

Python 實(shí)現(xiàn)

def relu(x):
 return np.maximum(0, x)
y = relu(x)
plt.plot(x, y)
plt.title("ReLU Activation Function")
plt.show()

4.Leaky ReLU

Leaky ReLU 是 ReLU 的變種,允許負(fù)值通過(guò)一個(gè)很小的斜率,公式為

圖片圖片

特點(diǎn)

  • 解決了 ReLU 函數(shù)中神經(jīng)元“死亡”的問(wèn)題。
  • 允許少量的負(fù)值梯度流過(guò),從而保持神經(jīng)元的更新。

python 實(shí)現(xiàn)

def leaky_relu(x, alpha=0.01):
 return np.where(x > 0, x, alpha * x)
y = leaky_relu(x)
plt.plot(x, y)
plt.title("Leaky ReLU Activation Function")
plt.show()

5.PReLU

其公式為

圖片圖片

特點(diǎn)

  • 是 Leaky ReLU 的推廣,其中  是一個(gè)可訓(xùn)練的參數(shù)。
  • 更靈活,能適應(yīng)不同的數(shù)據(jù)分布。

Python實(shí)現(xiàn)

def prelu(x, alpha):
 return np.where(x > 0, x, alpha * x)
alpha = 0.1 # This would be learned during training
y = prelu(x, alpha)
plt.plot(x, y)
plt.title("Parametric ReLU Activation Function")
plt.show()

6.ELU

其公式為

圖片圖片

特點(diǎn)

  • 當(dāng) x > 0 時(shí),ELU 的行為與 ReLU 類(lèi)似,輸出為 x 本身。
  • 當(dāng) x ≤ 0 時(shí),ELU 輸出一個(gè)負(fù)值,形如 ,其中  是一個(gè)超參數(shù)。
  • 負(fù)值部分的平滑特性可以使得平均激活接近 0,從而加快收斂速度。
  • 相較于 ReLU,ELU 在負(fù)值部分具有更好的特性,可以減輕梯度消失問(wèn)題,同時(shí)保留了 ReLU 的大部分優(yōu)點(diǎn)。

Python 實(shí)現(xiàn)

def elu(x, alpha=1.0):
 return np.where(x > 0, x, alpha * (np.exp(x) - 1))
y = elu(x)
plt.plot(x, y)
plt.title("ELU Activation Function")
plt.show()

7.Softmax 函數(shù)

公式為

圖片圖片

特點(diǎn)

  • 常用于多分類(lèi)問(wèn)題的輸出層。
  • 輸出的是一個(gè)概率分布,所有輸出值的和為1。

python 實(shí)現(xiàn)

def softmax(x):
 exp_x = np.exp(x-np.max(x))
 return exp_x / exp_x.sum(axis=0)
y = softmax(x)
plt.plot(x, y)
plt.title("Softmax Activation Function")
plt.show()

責(zé)任編輯:武曉燕 來(lái)源: 程序員學(xué)長(zhǎng)
相關(guān)推薦

2024-11-07 08:26:31

神經(jīng)網(wǎng)絡(luò)激活函數(shù)信號(hào)

2024-10-17 13:05:35

神經(jīng)網(wǎng)絡(luò)算法機(jī)器學(xué)習(xí)深度學(xué)習(xí)

2024-09-12 08:28:32

2024-12-02 01:10:04

神經(jīng)網(wǎng)絡(luò)自然語(yǔ)言DNN

2024-10-05 23:00:35

2024-11-15 13:20:02

2025-02-21 08:29:07

2024-10-28 00:38:10

2024-12-12 00:29:03

2024-09-20 07:36:12

2024-09-26 07:39:46

2024-11-05 12:56:06

機(jī)器學(xué)習(xí)函數(shù)MSE

2024-10-16 07:58:48

2024-12-03 08:16:57

2024-07-17 09:32:19

2024-09-23 09:12:20

2024-08-01 08:41:08

2025-02-17 13:09:59

深度學(xué)習(xí)模型壓縮量化

2024-08-23 09:06:35

機(jī)器學(xué)習(xí)混淆矩陣預(yù)測(cè)

2024-09-18 16:42:58

機(jī)器學(xué)習(xí)評(píng)估指標(biāo)模型
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)