Skip to content

Commit 925d5c9

Browse files
committed
Theano 模块完成
Former-commit-id: 67ded14 Former-commit-id: d1a5ba9e0b23e7ecc6e6a10a9524b2db04c287e8 [formerly 6e045bfd3332b4e97310ea8c7055c7c97b40dc15] [formerly e8fe7af19d17a0e316fd76073bcd25aecaaf9854 [formerly 7eaf5fbcd2f0a4ebc6561e7e297c598a5360fdf3]] [formerly 65669abce578abbe2fa828ce5065d9cd4f9dbeee [formerly 3569510087dc512a9e319979bb8a673ccace684e] [formerly 08815b8421f6b94ba77982a75e7511cdbfd49f6a [formerly 452b9541a938effc6d0d66c2f1a6873af2782ea4]]] [formerly ae3a7b06cb2ffba47d0a76440ab63514a03ab50f [formerly 951e01aca5f7877fe3150321970477f4e9abdaff] [formerly 53fc76526d719c863058fff4c8f4fbd332bd9bd2 [formerly b56937b0fc4fed1ecda2e7ad53b4f29a73a0e569]] [formerly fd13f0d33cbaabbe51612771538481d0d09052c1 [formerly db77d8bb57d6a0bd3b6ba0f388e464f89c530041] [formerly 0f3317fa97c2084788e43e9c649a8f88450cbba1 [formerly 3f1033f]]]] Former-commit-id: 6f7b887589fc210e1d1ec87b3aadecf369b6fee3 [formerly f48cf85686dcff9b257fcb4ff839ad4ace5b592f] [formerly 041642365b5a170b9eeef0da0dc6c89987810542 [formerly 634315bac290358a5a03693c8df02c431b4a69cf]] [formerly 40c9d19bc22edd41963832c6df11306f94f068f0 [formerly ddb864a7c6c402b7ad519683e3d7c839bca190dd] [formerly a10b8976407187593c15ff5d237aa0e424e38788 [formerly 41eb956fc3ec3621265415cc2536977de3cde952]]] Former-commit-id: 4b974aa2b0b2692672c074f020f6d0a312014b1c [formerly 498d9fbf415832d0550f2d023036e04dedc23094] [formerly 65a653358f855573fb39c075f252a70232211b86 [formerly f1cb3096297f07f5b20cd6f72d9720c959bd50d1]] Former-commit-id: dc1a39f52ccce78ad808cdacbdcc8f5d7cb1b1f9 [formerly 00d7c54b549738e69a10d4bc0ebfebc3da7e7e9e] Former-commit-id: 892b3a283065f86879d5b82a0b5a456d86176eb0
1 parent fe853bf commit 925d5c9

12 files changed

+167
-54
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8cc3cb86c9bf006a8ff1c1aa7142de47e9f5d626
1+
bdc98c636d9472e7e2c89510804d52fcdcdd57ca
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5f516a9ea310bc7d00008980699c4aadbe508050
1+
06e4fb887bb36bbd062dfabc353d366f01c2bbd3

09. theano/09.17 operator and elementwise operations.ipynb

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ee7fe369c9693b124bacb59e4be37e4ba9b1f5cb
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
c46ad708187eae04142a4ee206e3c6b1e460a933

09. theano/09.19 tensor conv.ipynb

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Theano tensor 模块:conv 子模块"
8+
]
9+
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"`conv` 是 `tensor` 中处理卷积神经网络的子模块。"
15+
]
16+
},
17+
{
18+
"cell_type": "markdown",
19+
"metadata": {},
20+
"source": [
21+
"## 卷积"
22+
]
23+
},
24+
{
25+
"cell_type": "markdown",
26+
"metadata": {},
27+
"source": [
28+
"这里只介绍二维卷积:\n",
29+
"\n",
30+
"`T.nnet.conv2d(input, filters, input_shape=None, filter_shape=None, border_mode='valid', subsample=(1, 1), filter_flip=True, image_shape=None, **kwargs)`\n",
31+
"\n",
32+
"`conv2d` 函数接受两个输入:\n",
33+
"\n",
34+
"- `4D` 张量 `input`,其形状如下:\n",
35+
" \n",
36+
" `[b, ic, i0, i1]`\n",
37+
" \n",
38+
" \n",
39+
"- `4D` 张量 `filter` ,其形状如下:\n",
40+
" \n",
41+
" `[oc, ic, f0, f1]`\n",
42+
" \n",
43+
"`border_mode` 控制输出大小:\n",
44+
"\n",
45+
"- `'valid'`:输出形状:\n",
46+
"\n",
47+
" `[b, oc, i0 - f0 + 1, i1 - f1 + 1]`\n",
48+
" \n",
49+
"- `'full'`:输出形状:\n",
50+
"\n",
51+
" `[b, oc, i0 + f0 - 1, i1 + f1 - 1]`"
52+
]
53+
},
54+
{
55+
"cell_type": "markdown",
56+
"metadata": {},
57+
"source": [
58+
"## 池化"
59+
]
60+
},
61+
{
62+
"cell_type": "markdown",
63+
"metadata": {},
64+
"source": [
65+
"池化操作:\n",
66+
"\n",
67+
"`T.signal.downsample.max_pool_2d(input, ds, ignore_border=None, st=None, padding=(0, 0), mode='max')`\n",
68+
"\n",
69+
"`input` 池化操作在其最后两维进行。\n",
70+
"\n",
71+
"`ds` 是池化区域的大小,用长度为 2 的元组表示。\n",
72+
"\n",
73+
"`ignore_border` 设为 `Ture` 时,`(5, 5)` 在 `(2, 2)` 的池化下会变成 `(2, 2)`(5 % 2 == 1,多余的 1 个被舍去了),否则是 `(3, 3)`。"
74+
]
75+
},
76+
{
77+
"cell_type": "markdown",
78+
"metadata": {},
79+
"source": [
80+
"## MNIST 卷积神经网络形状详解"
81+
]
82+
},
83+
{
84+
"cell_type": "markdown",
85+
"metadata": {},
86+
"source": [
87+
"```python\n",
88+
"def model(X, w, w2, w3, w4, p_drop_conv, p_drop_hidden):\n",
89+
" \n",
90+
" # X: 128 * 1 * 28 * 28\n",
91+
" # w: 32 * 1 * 3 * 3\n",
92+
" # full mode\n",
93+
" # l1a: 128 * 32 * (28 + 3 - 1) * (28 + 3 - 1)\n",
94+
" l1a = rectify(conv2d(X, w, border_mode='full'))\n",
95+
" # l1a: 128 * 32 * 30 * 30\n",
96+
" # ignore_border False\n",
97+
" # l1: 128 * 32 * (30 / 2) * (30 / 2)\n",
98+
" l1 = max_pool_2d(l1a, (2, 2), ignore_border=False)\n",
99+
" l1 = dropout(l1, p_drop_conv)\n",
100+
"\n",
101+
" # l1: 128 * 32 * 15 * 15\n",
102+
" # w2: 64 * 32 * 3 * 3\n",
103+
" # valid mode\n",
104+
" # l2a: 128 * 64 * (15 - 3 + 1) * (15 - 3 + 1)\n",
105+
" l2a = rectify(conv2d(l1, w2)) \n",
106+
" # l2a: 128 * 64 * 13 * 13\n",
107+
" # l2: 128 * 64 * (13 / 2 + 1) * (13 / 2 + 1)\n",
108+
" l2 = max_pool_2d(l2a, (2, 2), ignore_border=False)\n",
109+
" l2 = dropout(l2, p_drop_conv)\n",
110+
"\n",
111+
" # l2: 128 * 64 * 7 * 7\n",
112+
" # w3: 128 * 64 * 3 * 3\n",
113+
" # l3a: 128 * 128 * (7 - 3 + 1) * (7 - 3 + 1)\n",
114+
" l3a = rectify(conv2d(l2, w3))\n",
115+
" # l3a: 128 * 128 * 5 * 5\n",
116+
" # l3b: 128 * 128 * (5 / 2 + 1) * (5 / 2 + 1)\n",
117+
" l3b = max_pool_2d(l3a, (2, 2), ignore_border=False) \n",
118+
" # l3b: 128 * 128 * 3 * 3\n",
119+
" # l3: 128 * (128 * 3 * 3)\n",
120+
" l3 = T.flatten(l3b, outdim=2)\n",
121+
" l3 = dropout(l3, p_drop_conv)\n",
122+
" \n",
123+
" # l3: 128 * (128 * 3 * 3)\n",
124+
" # w4: (128 * 3 * 3) * 625\n",
125+
" # l4: 128 * 625\n",
126+
" l4 = rectify(T.dot(l3, w4))\n",
127+
" l4 = dropout(l4, p_drop_hidden)\n",
128+
"\n",
129+
" # l5: 128 * 625\n",
130+
" # w5: 625 * 10\n",
131+
" # pyx: 128 * 10\n",
132+
" pyx = softmax(T.dot(l4, w_o))\n",
133+
" return l1, l2, l3, l4, pyx\n",
134+
"```"
135+
]
136+
}
137+
],
138+
"metadata": {
139+
"kernelspec": {
140+
"display_name": "Python 2",
141+
"language": "python",
142+
"name": "python2"
143+
},
144+
"language_info": {
145+
"codemirror_mode": {
146+
"name": "ipython",
147+
"version": 2
148+
},
149+
"file_extension": ".py",
150+
"mimetype": "text/x-python",
151+
"name": "python",
152+
"nbconvert_exporter": "python",
153+
"pygments_lexer": "ipython2",
154+
"version": "2.7.6"
155+
}
156+
},
157+
"nbformat": 4,
158+
"nbformat_minor": 0
159+
}

README.md.REMOVED.git-id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f0c9b91150156d860e5fbbede553f1141d28198b
1+
db394a43c7201a8bb8370581a23c0cd90ec08137
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3396c745ae693f489dfb7131ff69dfd45c0a2980
1+
6c2d8fb3291b8ca78c0c949466d436c24ab71f0e

0 commit comments

Comments
 (0)