Skip to content

Commit

Permalink
update autodiff.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzomi committed Oct 2, 2022
1 parent b209173 commit 7c221b3
Show file tree
Hide file tree
Showing 25 changed files with 10 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Frontend/AutoDiff/05.forward_mode.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
"\n",
"> 前向模式(Forward Automatic Differentiation,也叫做 tangent mode AD)或者前向累积梯度(前向模式)\n",
"\n",
"![](images/[email protected])\n",
"\n",
"前向自动微分中,从计算图的起点开始,沿着计算图边的方向依次向前计算,最终到达计算图的终点。它根据自变量的值计算出计算图中每个节点的值 以及其导数值,并保留中间结果。一直得到整个函数的值和其导数值。整个过程对应于一元复合函数求导时从最内层逐步向外层求导。\n",
"\n",
"![](images/WX20220522-180607@2x.png)\n",
"![](images/forward_mode.png)\n",
"\n",
"简单确实简单,可以总结前向自动微分关键步骤为:\n",
"\n",
Expand Down Expand Up @@ -123,7 +125,7 @@
" dx = self.dx - other.dx\n",
" elif isinstance(other, float):\n",
" x = self.x - other\n",
" ex = self.dx\n",
" dx = self.dx\n",
" else:\n",
" return NotImplementedError\n",
" return ADTangent(x, dx)\n",
Expand Down Expand Up @@ -154,7 +156,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"以公式5为例\n",
"以下面为例\n",
"\n",
"$$\n",
"f(x1,x2)=ln(x1)+x1x2−sin(x2) \\tag{1}\n",
Expand All @@ -179,9 +181,9 @@
}
],
"source": [
"x = ADTangent(x=2., dx=1)\n",
"y = ADTangent(x=5., dx=0)\n",
"f = ADTangent.log(x) + x * y - ADTangent.sin(y)\n",
"x1 = ADTangent(x=2., dx=1)\n",
"x2 = ADTangent(x=5., dx=0)\n",
"f = ADTangent.log(x) + x * x2 - ADTangent.sin(x2)\n",
"print(f)"
]
},
Expand Down
Binary file added Frontend/AutoDiff/images/.DS_Store
Binary file not shown.
Binary file added Frontend/AutoDiff/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Frontend/AutoDiff/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Frontend/AutoDiff/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Frontend/AutoDiff/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Frontend/AutoDiff/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Frontend/AutoDiff/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Frontend/AutoDiff/images/ast.graffle
Binary file not shown.
Binary file added Frontend/AutoDiff/images/ast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Frontend/AutoDiff/images/forward mode.graffle
Binary file not shown.
Binary file added Frontend/AutoDiff/images/forward_mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Frontend/AutoDiff/images/jacobian.graffle
Binary file not shown.
Binary file added Frontend/AutoDiff/images/jacobian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added Frontend/AutoDiff/images/operator_overload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Frontend/AutoDiff/images/parameter.graffle
Binary file not shown.
Binary file added Frontend/AutoDiff/images/parameter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Frontend/AutoDiff/images/reversed mode.graffle
Binary file not shown.
Binary file added Frontend/AutoDiff/images/reversed_mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Frontend/AutoDiff/images/tangent_adjoint.graffle
Binary file not shown.
Binary file added Frontend/AutoDiff/images/tangent_adjoint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Frontend/Foundation/02.fundamentals.pptx
Binary file not shown.
Binary file modified Frontend/Foundation/03.history.pptx
Binary file not shown.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
|1|自动微分|01 基本介绍|[silde](./Frontend/AutoDiff/01.introduction.pptx), [video](https://www.bilibili.com/video/BV1FV4y1T7zp/), [article](https://zhuanlan.zhihu.com/p/518198564)|
| |自动微分|02 什么是微分|[silde](./Frontend/AutoDiff/02.base_concept.pptx), [video](https://www.bilibili.com/video/BV1Ld4y1M7GJ/), [article](https://zhuanlan.zhihu.com/p/518198564)|
| |自动微分|03 数学计算模式|[silde](./Frontend/AutoDiff/03.grad_mode.pptx), [video](https://www.bilibili.com/video/BV1zD4y117bL/), [article](https://zhuanlan.zhihu.com/p/518296942)|
| |自动微分|04 三种实现方式|[silde](./Frontend/AutoDiff/04.grad_mode.pptx), [video](https://www.bilibili.com/video/BV1BN4y1P76t/), [article](https://zhuanlan.zhihu.com/p/520065656)|
| |自动微分|05 手把手实现正向微分框架|[silde](./Frontend/AutoDiff/05.forward_mode.ipynb), [video](https://www.bilibili.com/video/BV1Ne4y1p7WU/), [article](https://zhuanlan.zhihu.com/p/520451681)|
|||||

**底层编译技术**
Expand Down

0 comments on commit 7c221b3

Please sign in to comment.