Fully Connect Feedforward Network


Fully Connect Feedforward Network(全连接前馈网络)

在这里插入图片描述
将多个Logistic Regression以不同的结构前后连接起来,叫做Neural Network,其中每一个Logistic Regression是一个neuron。

结构

在这里插入图片描述

  • input layer,输入层(严格来说input layer其实不是一个layer,并不由neural所组成的)
  • output layer,输出层
  • hidden layer,隐藏层

Neural输出公式

o u t p u t = f ( w ⋅ x + b ) output=f(w\cdot x+b) output=f(wx+b)

  • x x x:前一层输出
  • w w w:全连接权值,作为neural的参数
  • b b b:偏置,作为neural的参数
  • f ( x ) f(x) f(x):激励函数, ① ① 模拟神经元兴奋或抑制 ② ② 做非线性处理

Layer输出公式

o u t p u t = f ( W x + b ) output = f(W x+b) output=f(Wx+b)

  • x x x:前一层输出
  • W W W:整层neural的全连接权值matrix [ w 1 w 2 ⋮ ] \begin{bmatrix}w_1\\w_2\\\vdots \end{bmatrix} w1w2
  • b b b:整层neural的偏置vector [ b 1 b 2 ⋮ ] \begin{bmatrix}b_1\\b_2\\\vdots \end{bmatrix} b1b2
  • f ( x ) f(x) f(x):激励函数

Example

假设:

  • 前一层输出vector x x x [ 1 − 1 ] \begin{bmatrix}1\\-1 \end{bmatrix} [11]
  • 本层全连接权值matrix W W W [ w 11     w 21 w 12     w 22 ] = [ 1     − 2 − 1     1 ] \begin{bmatrix}w_{11} \ \ \ w_{21}\\ w_{12} \ \ \ w_{22} \end{bmatrix}=\begin{bmatrix}1 \ \ \ -2\\ -1 \ \ \ 1 \end{bmatrix} [w11   w21w12   w22]=[1   21   1]
    ( w 11 w_{11} w11表示前一层输出 x 1 x_1 x1与本层Neural 1 _1 1的连接权值; w 21 w_{21} w21表示前一层输出 x 2 x_2 x2与本层Neural 1 _1 1的连接权值)
  • 本层偏置vector b b b [ 1 0 ] \begin{bmatrix}1\\0 \end{bmatrix} [10]
  • 激励函数 σ \sigma σ:sigmoid function

在这里插入图片描述
则本层输出:

l a y e r   o u t p u t = σ ( W x + b ) = σ ( [ 1     − 2 − 1     1 ] [ 1 − 1 ] + [ 1 0 ] ) = σ ( [ 4 − 2 ] ) = [ 0.98 0.12 ] layer\ output = \sigma(Wx+b)= \sigma(\begin{bmatrix}1 \ \ \ -2\\ -1 \ \ \ 1 \end{bmatrix} \begin{bmatrix}1\\-1 \end{bmatrix}+\begin{bmatrix}1\\0 \end{bmatrix})=\sigma(\begin{bmatrix}4\\-2 \end{bmatrix})=\begin{bmatrix}0.98\\0.12 \end{bmatrix} layer output=σ(Wx+b)=σ([1   21   1][11]+[10])=σ([42])=[0.980.12]


hidden layers输出公式

h i d d e n   l a y e r s   o u t p u t = f ( W n ⋯ f ( W 2 f ( W 1 x + b 1 ) + b 2 ) ⋯ + b n ) hidden\ layers\ output = f(W_n\cdots f(W_2f(W_1 x+b_1)+b_2)\cdots +b_n) hidden layers output=f(Wnf(W2f(W1x+b1)+b2)+bn)

  • W i W_i Wi b i b_i bi为各层的权值matrix和偏置vector
  • 公式仅表示hidden layer的输出

在这里插入图片描述


Output Layer输出公式

n e t w o r k   o u t p u t = s o f t m a x ( z ) network\ output = softmax(z) network output=softmax(z)

  • z z z是隐藏层输出的feature vector

output layer只是对hidden layers的输出利用softmax函数作归一化处理,突出极大值。hidden layers部分,可以看做feature extractor(特征提取器),代替了我们之前手动做feature engineering,feature transformation,经过这个feature extractor得到的 x 1 , x 2 , . . . , x k x_1,x_2,...,x_k x1,x2,...,xk就可以被当作一组新的feature vector,经过feature extractor转换后会得出比较好的feature,这个feature可以更容易将数据区分开。

output layer部分,它是一个softmax层,可以看做Multi-class classifier(多分类器),它是拿经过feature extractor转换后的feature进行分类的。


三步骤

Step 1:Network Structure

在这里插入图片描述
对于分类个体,其输入的feature vector的维数确定,input layer的维数与其相同,而output layer的维数则与类别数量相同,但hidden layer的结构未知,而设计这个network structure是最为关键的部分。

Step 2:Goodness of Network

Multi-class classification问题中,常采用cross entropy,判断分类的好坏
l ( y , y ^ ) = − ∑ i = 1 n y ^ i l n y i l(y,\hat{y})=-\sum\limits_{i=1}^{n}\hat{y}_i lny_i l(y,y^)=i=1ny^ilnyi

  • y y y: 目标分类结果
  • y ^ \hat{y} y^:预测分类结果
  • n n n:表示分类类别数

我们把training data里任意一个样本点 x n x^n xn送到neural network里面,输出一个预测标签 y n y^n yn,我们把这个output跟样本点本身的label标注的target y ^ n \hat{y}^n y^n作cross entropy,这个交叉熵定义了output y n y^n yn和target y ^ n \hat{y}^n y^n之间的距离 l n ( θ ) l^n(\theta) ln(θ),如果cross entropy比较大的话,说明output和target之间距离很远,这个network的parameter预测该样本的loss是比较大的。

Step 3:Backpropagation

接下来就是调整参数,让这个cross entropy越小越好,需要把一般部分data的cross entropy都sum起来,得到一个total loss L = ∑ n = 1 N l n L=\sum\limits_{n=1}^Nl^n L=n=1Nln,得到total loss之后通过Backpropagation的方法对网络中的所有参数( w w w b b b)进行更新,最终是total loss达到最低值。
在这里插入图片描述

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值