当前位置: 首页 > news >正文

定制版网站建设详细报价怎样做推广更有效

定制版网站建设详细报价,怎样做推广更有效,网站建设入门,巴中微信开发 做网站要推导反向传播算法,并了解每一层的参数梯度如何计算,以及每一层的梯度受到哪些值的影响,我们使用一个简单的神经网络结构: 输入层有2个节点一个有2个节点的隐藏层,激活函数是ReLU一个输出节点,激活函数是…

要推导反向传播算法,并了解每一层的参数梯度如何计算,以及每一层的梯度受到哪些值的影响,我们使用一个简单的神经网络结构:

  • 输入层有2个节点
  • 一个有2个节点的隐藏层,激活函数是ReLU
  • 一个输出节点,激活函数是线性激活(即没有激活函数)

假设权重矩阵和偏置如下:

  • 输入层到隐藏层的权重矩阵 W 1 W_1 W1 2 × 2 2 \times 2 2×2
  • 隐藏层的偏置向量 b 1 b_1 b1 2 × 1 2 \times 1 2×1
  • 隐藏层到输出层的权重矩阵 W 2 W_2 W2 2 × 1 2 \times 1 2×1
  • 输出层的偏置向量 b 2 b_2 b2是一个标量

输入为 x = [ x 1 , x 2 ] x = [x_1, x_2] x=[x1,x2],期望输出为 y y y,损失函数为均方误差(MSE)。

前向传播:

  1. 计算隐藏层的输入:
    z 1 = W 1 ⋅ x + b 1 z_1 = W_1 \cdot x + b_1 z1=W1x+b1
  2. 计算隐藏层的激活:
    a 1 = ReLU ( z 1 ) a_1 = \text{ReLU}(z_1) a1=ReLU(z1)
  3. 计算输出层的输入:
    z 2 = W 2 T ⋅ a 1 + b 2 z_2 = W_2^T \cdot a_1 + b_2 z2=W2Ta1+b2
  4. 输出值:
    y ^ = z 2 \hat{y} = z_2 y^=z2
  5. 计算损失:
    L = 1 2 ( y ^ − y ) 2 L = \frac{1}{2} (\hat{y} - y)^2 L=21(y^y)2

反向传播:

  1. 计算输出层的梯度:

    • 损失函数对输出层输入的梯度:
      ∂ L ∂ z 2 = y ^ − y \frac{\partial L}{\partial z_2} = \hat{y} - y z2L=y^y
  2. 计算从输出层到隐藏层的梯度:

    • 隐藏层激活对权重的梯度:
      ∂ L ∂ W 2 = ∂ L ∂ z 2 ⋅ a 1 \frac{\partial L}{\partial W_2} = \frac{\partial L}{\partial z_2} \cdot a_1 W2L=z2La1
    • 隐藏层激活对偏置的梯度:
      ∂ L ∂ b 2 = ∂ L ∂ z 2 \frac{\partial L}{\partial b_2} = \frac{\partial L}{\partial z_2} b2L=z2L
  3. 计算隐藏层的梯度:

    • 损失函数对隐藏层激活的梯度:
      ∂ L ∂ a 1 = W 2 ⋅ ∂ L ∂ z 2 \frac{\partial L}{\partial a_1} = W_2 \cdot \frac{\partial L}{\partial z_2} a1L=W2z2L
    • 隐藏层对隐藏层输入的梯度(ReLU的梯度):
      ∂ L ∂ z 1 = ∂ L ∂ a 1 ⋅ ReLU ′ ( z 1 ) \frac{\partial L}{\partial z_1} = \frac{\partial L}{\partial a_1} \cdot \text{ReLU}'(z_1) z1L=a1LReLU(z1)
      • ReLU梯度 ReLU ′ ( z 1 ) \text{ReLU}'(z_1) ReLU(z1) z 1 > 0 z_1 > 0 z1>0时为1,否则为0
  4. 计算从输入层到隐藏层的梯度:

    • 输入对权重的梯度:
      ∂ L ∂ W 1 = ∂ L ∂ z 1 ⋅ x T \frac{\partial L}{\partial W_1} = \frac{\partial L}{\partial z_1} \cdot x^T W1L=z1LxT
    • 输入对偏置的梯度:
      ∂ L ∂ b 1 = ∂ L ∂ z 1 \frac{\partial L}{\partial b_1} = \frac{\partial L}{\partial z_1} b1L=z1L

详细推导实例:

假设:

  • x = [ 1 , 2 ] x = [1, 2] x=[1,2]
  • y = 3 y = 3 y=3
  • W 1 = [ 0.5 0.2 0.3 0.7 ] W_1 = \begin{bmatrix} 0.5 & 0.2 \\ 0.3 & 0.7 \end{bmatrix} W1=[0.50.30.20.7]
  • b 1 = [ 0.1 0.2 ] b_1 = \begin{bmatrix} 0.1 \\ 0.2 \end{bmatrix} b1=[0.10.2]
  • W 2 = [ 0.6 0.9 ] W_2 = \begin{bmatrix} 0.6 \\ 0.9 \end{bmatrix} W2=[0.60.9]
  • b 2 = 0.3 b_2 = 0.3 b2=0.3

前向传播:
1.
z 1 = W 1 ⋅ x + b 1 = [ 0.5 0.2 0.3 0.7 ] ⋅ [ 1 2 ] + [ 0.1 0.2 ] = [ 1.0 1.9 ] z_1 = W_1 \cdot x + b_1 = \begin{bmatrix} 0.5 & 0.2 \\ 0.3 & 0.7 \end{bmatrix} \cdot \begin{bmatrix} 1 \\ 2 \end{bmatrix} + \begin{bmatrix} 0.1 \\ 0.2 \end{bmatrix} = \begin{bmatrix} 1.0 \\ 1.9 \end{bmatrix} z1=W1x+b1=[0.50.30.20.7][12]+[0.10.2]=[1.01.9]
2.
a 1 = ReLU ( z 1 ) = ReLU ( [ 1.0 1.9 ] ) = [ 1.0 1.9 ] a_1 = \text{ReLU}(z_1) = \text{ReLU}(\begin{bmatrix} 1.0 \\ 1.9 \end{bmatrix}) = \begin{bmatrix} 1.0 \\ 1.9 \end{bmatrix} a1=ReLU(z1)=ReLU([1.01.9])=[1.01.9]
3.
z 2 = W 2 T ⋅ a 1 + b 2 = [ 0.6 0.9 ] T ⋅ [ 1.0 1.9 ] + 0.3 = 2.46 z_2 = W_2^T \cdot a_1 + b_2 = \begin{bmatrix} 0.6 \\ 0.9 \end{bmatrix}^T \cdot \begin{bmatrix} 1.0 \\ 1.9 \end{bmatrix} + 0.3 = 2.46 z2=W2Ta1+b2=[0.60.9]T[1.01.9]+0.3=2.46
4.
y ^ = z 2 = 2.46 \hat{y} = z_2 = 2.46 y^=z2=2.46
5.
L = 1 2 ( 2.46 − 3 ) 2 = 0.1458 L = \frac{1}{2} (2.46 - 3)^2 = 0.1458 L=21(2.463)2=0.1458

反向传播:
1.
∂ L ∂ z 2 = 2.46 − 3 = − 0.54 \frac{\partial L}{\partial z_2} = 2.46 - 3 = -0.54 z2L=2.463=0.54

  1. ∂ L ∂ W 2 = [ − 0.54 ] ⋅ [ 1.0 1.9 ] = [ − 0.54 ⋅ 1.0 − 0.54 ⋅ 1.9 ] = [ − 0.54 − 1.026 ] \frac{\partial L}{\partial W_2} = \begin{bmatrix} -0.54 \end{bmatrix} \cdot \begin{bmatrix} 1.0 \\ 1.9 \end{bmatrix} = \begin{bmatrix} -0.54 \cdot 1.0 \\ -0.54 \cdot 1.9 \end{bmatrix} = \begin{bmatrix} -0.54 \\ -1.026 \end{bmatrix} W2L=[0.54][1.01.9]=[0.541.00.541.9]=[0.541.026]
    ∂ L ∂ b 2 = − 0.54 \frac{\partial L}{\partial b_2} = -0.54 b2L=0.54

  2. ∂ L ∂ a 1 = [ 0.6 0.9 ] ⋅ − 0.54 = [ − 0.324 − 0.486 ] \frac{\partial L}{\partial a_1} = \begin{bmatrix} 0.6 \\ 0.9 \end{bmatrix} \cdot -0.54 = \begin{bmatrix} -0.324 \\ -0.486 \end{bmatrix} a1L=[0.60.9]0.54=[0.3240.486]
    ∂ L ∂ z 1 = ∂ L ∂ a 1 ⋅ ReLU ′ ( z 1 ) = [ − 0.324 − 0.486 ] ⋅ [ 1 1 ] = [ − 0.324 − 0.486 ] \frac{\partial L}{\partial z_1} = \frac{\partial L}{\partial a_1} \cdot \text{ReLU}'(z_1) = \begin{bmatrix} -0.324 \\ -0.486 \end{bmatrix} \cdot \begin{bmatrix} 1 \\ 1 \end{bmatrix} = \begin{bmatrix} -0.324 \\ -0.486 \end{bmatrix} z1L=a1LReLU(z1)=[0.3240.486][11]=[0.3240.486]

  3. ∂ L ∂ W 1 = ∂ L ∂ z 1 ⋅ x T = [ − 0.324 − 0.486 ] ⋅ [ 1 2 ] T = [ − 0.324 − 0.648 − 0.486 − 0.972 ] \frac{\partial L}{\partial W_1} = \frac{\partial L}{\partial z_1} \cdot x^T = \begin{bmatrix} -0.324 \\ -0.486 \end{bmatrix} \cdot \begin{bmatrix} 1 & 2 \end{bmatrix}^T = \begin{bmatrix} -0.324 & -0.648 \\ -0.486 & -0.972 \end{bmatrix} W1L=z1LxT=[0.3240.486][12]T=[0.3240.4860.6480.972]
    ∂ L ∂ b 1 = [ − 0.324 − 0.486 ] \frac{\partial L}{\partial b_1} = \begin{bmatrix} -0.324 \\ -0.486 \end{bmatrix} b1L=[0.3240.486]

从上述示例可以看到,每层的梯度依赖于上一层的激活值和当前层的损失梯度。梯度的传递通过链式法则一步步向前传播,从最初的损失函数计算开始,直到最终的输入层的权重和偏置。


文章转载自:
http://adverbialize.dkqr.cn
http://lantsang.dkqr.cn
http://prongy.dkqr.cn
http://med.dkqr.cn
http://graftabl.dkqr.cn
http://penance.dkqr.cn
http://sulfuret.dkqr.cn
http://consistence.dkqr.cn
http://redouble.dkqr.cn
http://versailles.dkqr.cn
http://geo.dkqr.cn
http://ferritin.dkqr.cn
http://triffidian.dkqr.cn
http://agility.dkqr.cn
http://dichromatism.dkqr.cn
http://pieceworker.dkqr.cn
http://mastery.dkqr.cn
http://choreopoem.dkqr.cn
http://puffingly.dkqr.cn
http://kinetochore.dkqr.cn
http://actionability.dkqr.cn
http://vestibulocerebellar.dkqr.cn
http://calculous.dkqr.cn
http://sinapism.dkqr.cn
http://gurdwara.dkqr.cn
http://tonsillitis.dkqr.cn
http://daunomycin.dkqr.cn
http://gigman.dkqr.cn
http://nashville.dkqr.cn
http://bedtime.dkqr.cn
http://feretrum.dkqr.cn
http://worcestershire.dkqr.cn
http://poliovirus.dkqr.cn
http://hinny.dkqr.cn
http://bluish.dkqr.cn
http://galibi.dkqr.cn
http://novial.dkqr.cn
http://antidepressive.dkqr.cn
http://mammon.dkqr.cn
http://anguine.dkqr.cn
http://sulphamethazine.dkqr.cn
http://atelic.dkqr.cn
http://skua.dkqr.cn
http://perspectively.dkqr.cn
http://monarchial.dkqr.cn
http://farrier.dkqr.cn
http://mellitum.dkqr.cn
http://harmonize.dkqr.cn
http://elasmobranchiate.dkqr.cn
http://disimprisonment.dkqr.cn
http://mount.dkqr.cn
http://headteacher.dkqr.cn
http://vindicatory.dkqr.cn
http://undoable.dkqr.cn
http://pantomorphic.dkqr.cn
http://wonky.dkqr.cn
http://escapology.dkqr.cn
http://communicator.dkqr.cn
http://anchylose.dkqr.cn
http://stronghearted.dkqr.cn
http://bulbul.dkqr.cn
http://galvanoscopy.dkqr.cn
http://violative.dkqr.cn
http://micelle.dkqr.cn
http://subconical.dkqr.cn
http://socialism.dkqr.cn
http://caustic.dkqr.cn
http://gadolinite.dkqr.cn
http://calefactory.dkqr.cn
http://vicennial.dkqr.cn
http://corporativism.dkqr.cn
http://database.dkqr.cn
http://pentacarpellary.dkqr.cn
http://bagwash.dkqr.cn
http://educated.dkqr.cn
http://tarim.dkqr.cn
http://ingratitude.dkqr.cn
http://deprecation.dkqr.cn
http://mainspring.dkqr.cn
http://catastrophic.dkqr.cn
http://diligency.dkqr.cn
http://calculus.dkqr.cn
http://indochina.dkqr.cn
http://arillus.dkqr.cn
http://shortcake.dkqr.cn
http://ploughshoe.dkqr.cn
http://blindage.dkqr.cn
http://gastraea.dkqr.cn
http://fitter.dkqr.cn
http://skinner.dkqr.cn
http://transmigration.dkqr.cn
http://tele.dkqr.cn
http://divination.dkqr.cn
http://sdlc.dkqr.cn
http://instinct.dkqr.cn
http://improve.dkqr.cn
http://sociably.dkqr.cn
http://sally.dkqr.cn
http://micros.dkqr.cn
http://succussive.dkqr.cn
http://www.hrbkazy.com/news/59532.html

相关文章:

  • 自己做网站服务器可以吗排名seo公司哪家好
  • 广州那里有学做拼多多网站的视频优化是什么意思
  • 建手机wap网站大概多少钱嘉兴seo外包服务商
  • 朋友用我的vps做网站搜索引擎优化自然排名
  • jsp mysql 开发网站开发西安网站建设制作公司
  • wordpress顺风车源码王通seo教程
  • 网站需要每个城市做推广吗我想在百度上做广告怎么做
  • html5做网站seo网络推广软件
  • 慧聪网b2b杭州网站seo外包
  • 网站开发入帐分录网站优化公司哪家效果好
  • 新闻网站给企业做专题策划最近的国内新闻
  • 人和机械网站建设网络宣传的方法有哪些
  • 做私房蛋糕在哪些网站写东西济南seo优化外包服务
  • 基于html css的网站设计seo优化网络公司
  • 网页与网站设计 什么是属性深圳互联网推广公司
  • 哪个网站做h5好谈谈对seo的理解
  • 网站制作学什么软件有哪些携程: 2023年旅行搜索上涨超900%
  • 深圳高端网站建设电话网页设计主题参考
  • 网站宣传的传统方式有哪些站长工具关键词查询
  • 二级域名做网址导航大全网站大数据营销 全网推广
  • 厦门市湖里区建设局网站关键词歌词图片
  • 做网站要执照吗seo服务工程
  • 青岛网站建设优化中山网站建设
  • 自己做的网站程序怎么发布每日新闻摘要30条
  • asp系统网站怎么做优化推广页面制作
  • 做移动网站点击软件吗app开发制作
  • layui 企业网站模板济南优化哪家好
  • 小程序建站平台哪个好网站查询ip地址
  • 515ppt网站建设广告资源对接平台
  • wp建站模板免费引流人脉推广软件