Skip to content

Commit e954333

Browse files
committed
添加了 R-op 和 L-op
1 parent 5c95e0a commit e954333

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

09. theano/09.02 theano basics.ipynb

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@
310310
"- `b` int8\n",
311311
"- `w` int16\n",
312312
"- `i` int32\n",
313+
"- `l` int64\n",
313314
"- `d` float64\n",
314315
"- `f` float32\n",
315316
"- `c` complex64\n",
@@ -700,7 +701,7 @@
700701
"[[ 1. 2.]\n",
701702
" [ 3. 4.]]\n",
702703
"the return value:\n",
703-
"<CudaNdarray object at 0x000000003403E430>\n",
704+
"<CudaNdarray object at 0x000000002902BF30>\n",
704705
"after update:\n",
705706
"[[ 0. 1.]\n",
706707
" [ 2. 3.]]\n"
@@ -803,6 +804,50 @@
803804
"source": [
804805
"`theano.gradient.jacobian` 用来计算雅可比矩阵,而 `theano.gradient.hessian` 可以用来计算 `Hessian` 矩阵。"
805806
]
807+
},
808+
{
809+
"cell_type": "markdown",
810+
"metadata": {},
811+
"source": [
812+
"## `R-op` 和 `L-op`"
813+
]
814+
},
815+
{
816+
"cell_type": "markdown",
817+
"metadata": {},
818+
"source": [
819+
"Rop 用来计算 $\\frac{\\partial f}{\\partial x}v$,Lop 用来计算 $v\\frac{\\partial f}{\\partial x}$:\n",
820+
"\n",
821+
"一个是雅可比矩阵与列向量的乘积,另一个是行向量与雅可比矩阵的乘积。"
822+
]
823+
},
824+
{
825+
"cell_type": "code",
826+
"execution_count": 28,
827+
"metadata": {
828+
"collapsed": false
829+
},
830+
"outputs": [
831+
{
832+
"data": {
833+
"text/plain": [
834+
"array([ 2., 2.])"
835+
]
836+
},
837+
"execution_count": 28,
838+
"metadata": {},
839+
"output_type": "execute_result"
840+
}
841+
],
842+
"source": [
843+
"W = T.dmatrix('W')\n",
844+
"V = T.dmatrix('V')\n",
845+
"x = T.dvector('x')\n",
846+
"y = T.dot(x, W)\n",
847+
"JV = T.Rop(y, W, V)\n",
848+
"f = theano.function([W, V, x], JV)\n",
849+
"f([[1, 1], [1, 1]], [[2, 2], [2, 2]], [0,1])"
850+
]
806851
}
807852
],
808853
"metadata": {

0 commit comments

Comments
 (0)