← All writing

Deep Learning

Notes on backpropagation through computational graphs, deriving gradient propagation with the chain rule and Jacobians.

Deep Learning

6.5 Back-Propagation

6.5.1 Computational Graphs

Here, we use each node in the graph to indicate a variable.

If a variable yy is computed by applying an operation to a variable xx, then we draw a directed edge from xx to yy.

6.5.2 Chain Rule of Calculus

We can generalize this beyond the scalar case.

Suppose that x∈Rm,y∈Rnx \in R^m, y ∈ R^n, g:Rm→Rn,f:Rn→Rg : R^m \rarr R^n, f:R^n \rarr R. If y=g(x),z=f(y)y = g(x), z = f(y). Then

\partz\partxi=∑i\partz\partyi\partyi\partxi\frac{\part z}{\part x_i} =\sum_{i} \frac{\part z}{\part y_i}\frac{\part y_i}{\part x_i}

In vector notation, this may be equivalently written as

∇yz=\partf(y)\party=(\partf(y)\party1\partf(y)\party2...\partf(y)\partyn)\party\partx=\partg(x)\partx=(\partg1(y)\partx1...\partgm(y)\partx1\partf(y)\partx2...\partgm(y)\partx2...\partf(y)\partxm...\partgm(y)\partxm)\nabla_yz = \frac{\part f(y)}{\part y} = \begin{pmatrix} \frac{\part f(y)}{\part y_1} \\ \frac{\part f(y)}{\part y_2} \\ ...\\ \frac{\part f(y)}{\part y_n} \end{pmatrix}\\\\ \frac{\part y}{\part x} = \frac{\part g(x)}{\part x} =\\ \begin{pmatrix} \frac{\part g_1(y)}{\part x_1} & ...& \frac{\part g_m(y)}{\part x_1}\\ \frac{\part f(y)}{\part x_2}&...&\frac{\part g_m(y)}{\part x_2} \\ ...\\ \frac{\part f(y)}{\part x_m}&...&\frac{\part g_m(y)}{\part x_m} \end{pmatrix}\\\\

The second matrix is the transposition of JgJ_g Jacobian matrix of gg

∇xz=\party\partx∇yz=JgT∇yz\nabla_xz =\frac{\part y}{\part x}\nabla_yz = J_g^T\nabla_yz

The back-propagation algorithm consists of performing such a Jacobian-gradient product for each operation in the graph.

多层感知机

X∈Rn×dX \in R^{n \times d} 表示nn个样本的小批量, 其中每个样本具有dd个输入特征。 对于具有hh个隐藏单元的单隐藏层多层感知机, 用H∈Rn×hH\in R^{n \times h}表示隐藏层的输出。隐藏层权重是W(1)∈Rd×h,b(1)∈RhW^{(1)}\in R ^{d \times h}, b^{(1) \in R^h}, 输出层则是W(2)∈Rh×q,b(2)∈RqW^{(2)}\in R ^{h \times q}, b^{(2) \in R^q}。所以输出O∈Rn×qO \in R^{n \times q}

H=σ(XW(1)+(b(1))T)O=HW(2)+(b(2))TH = \sigma(XW^{(1)} + (b^{(1)})^T)\\ O= HW^{(2)} + (b^{(2)})^T
← Back to ArchiveBack to top ↑

Comments

No approved comments yet.

Your display name and plain-text comment become public only after owner approval. No account or email is required.