Skip to content

Commit 56cc225

Browse files
committed
添加了静态的 HTML 文件
Former-commit-id: 0a23739 Former-commit-id: 55b028e60f58b3a6392368d07043b9bcfbb7fd68 [formerly 4baf6faa3ae671afb70f35853a5faebcd3f9eede] [formerly 92c269f18c65fd8820f17b0d94da4fc61756090a [formerly 6769512c4e98fbce459b74b4dccc0717644b2765]] [formerly fe368abc29479ea6d7975d6704b839b4c071476a [formerly 226a6650f0ee2381d5742c50594637ef5e9d4529] [formerly 7e6255d4645dbf80370506037ef820127ef7eedf [formerly 2763b4d9464dba961543883a04826c2a6b66fd52]]] [formerly 786d447ca560591734ab28752439ddb1246ed08c [formerly 0930ade9abbff8c847d7badbeef317fa0fa6f448] [formerly a60308d9ac38d495118b041a1cfea97a68289528 [formerly 12959f28936571a44e9d83caaf2bf4da5f0254ee]] [formerly 4072a382edeb1651a37c1528c2f8d6850aae14df [formerly 680dffec4bf302c36dc008abb625b829c3185aff] [formerly 9f9667d8193ee1af7f3bd48b3514577fcccf6890 [formerly 15cb732]]]] Former-commit-id: 953c9aa46269cb8c7076c4df77238cdd90c5e194 [formerly 5604ec0b6b1842f20f0d2f848acff9a59cbda33a] [formerly b533893d3ca0844452f149906a147100861b6c98 [formerly 4ad0d80c131e6cb43af669857a8d4bcedd33d8ac]] [formerly 3431118edec5e6df516465e6edb634469d4f008b [formerly 8b09659abc746ef4b2d3afc3f10544bf13b718aa] [formerly a0f4db2410d20522682eb52cf2e03f9fd5e425ae [formerly 00165d191fc0eb236806d4ef38100a7e1ec0984a]]] Former-commit-id: d8deb71db2014f8e3cc4d4e28e514dea1b7ec1ad [formerly ba8d2d60dfd47a7ade5b3d99b22e2c5a242981cf] [formerly 742896aea232e7d2ac5e0a326c0406697d858f07 [formerly aec35cb2acf1163e35e21d10c0217f862eca3698]] Former-commit-id: b88ad491302356538321e50ba94c42986a3384af [formerly aa67ef41dacb0a2fe1fa7f73ab43ea4f05053812] Former-commit-id: 4f30b96efbef636a0f0bdcb44492df6e01f45b71
1 parent 352e995 commit 56cc225

File tree

134 files changed

+536
-75
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+536
-75
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
713ccb0c837d616e4f75cc49a117c2297179862b
1+
8b3a5b7d7391ea7f4735ef7a7f28a6bb4197e215
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Theano 简介及其安装"
8+
]
9+
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"# 简介"
15+
]
16+
},
17+
{
18+
"cell_type": "markdown",
19+
"metadata": {},
20+
"source": [
21+
"`Theano` 是一个 `Python` 科学计算库,允许我们进行符号运算,并在 `CPU` 和 `GPU` 上执行。\n",
22+
"\n",
23+
"它最初由 `Montreal` 大学的机器学习研究者们所开发,用来进行机器学习的计算。\n",
24+
"\n",
25+
"按照[官网](http://deeplearning.net/software/theano/)上的说明,它拥有以下几个方面的特点:\n",
26+
"\n",
27+
"- 与 **Numpy, Scipy** 的紧密结合\n",
28+
"- **GPU** 加速\n",
29+
"- 高效的符号计算\n",
30+
"- 速度和稳定性\n",
31+
"- 动态生成 **C** 代码"
32+
]
33+
},
34+
{
35+
"cell_type": "markdown",
36+
"metadata": {},
37+
"source": [
38+
"## 使用 anaconda 安装 theano"
39+
]
40+
},
41+
{
42+
"cell_type": "markdown",
43+
"metadata": {},
44+
"source": [
45+
"`windows` 下,使用 `anaconda` 安装 `theano` 的命令为:\n",
46+
"\n",
47+
" conda install mingw libpython\n",
48+
" pip install theano\n",
49+
" \n",
50+
"`linux` 下,使用 `anaconda` 安装的命令为\n",
51+
" \n",
52+
" conda install theano\n",
53+
"\n",
54+
"安装好之后,还需要安装 `Cuda` 并进行 `GPU` 环境的配置,否则是不能利用 `GPU` 进行计算的,推荐使用 `linux/mac` 进行配置,具体方法可以参考[官网](http://deeplearning.net/software/theano/)上的配置说明。\n",
55+
"\n",
56+
"查看安装的版本:"
57+
]
58+
},
59+
{
60+
"cell_type": "code",
61+
"execution_count": 1,
62+
"metadata": {
63+
"collapsed": false,
64+
"scrolled": true
65+
},
66+
"outputs": [
67+
{
68+
"data": {
69+
"text/plain": [
70+
"'0.7.0.dev-54186290a97186b9c6b76317e007844529a352f4'"
71+
]
72+
},
73+
"execution_count": 1,
74+
"metadata": {},
75+
"output_type": "execute_result"
76+
}
77+
],
78+
"source": [
79+
"import theano\n",
80+
"\n",
81+
"theano.__version__"
82+
]
83+
},
84+
{
85+
"cell_type": "markdown",
86+
"metadata": {},
87+
"source": [
88+
"查看当前使用的 device:"
89+
]
90+
},
91+
{
92+
"cell_type": "code",
93+
"execution_count": 2,
94+
"metadata": {
95+
"collapsed": false
96+
},
97+
"outputs": [
98+
{
99+
"data": {
100+
"text/plain": [
101+
"'cpu'"
102+
]
103+
},
104+
"execution_count": 2,
105+
"metadata": {},
106+
"output_type": "execute_result"
107+
}
108+
],
109+
"source": [
110+
"theano.config.device"
111+
]
112+
},
113+
{
114+
"cell_type": "markdown",
115+
"metadata": {},
116+
"source": [
117+
"运行测试:"
118+
]
119+
},
120+
{
121+
"cell_type": "code",
122+
"execution_count": 3,
123+
"metadata": {
124+
"collapsed": false
125+
},
126+
"outputs": [
127+
{
128+
"name": "stderr",
129+
"output_type": "stream",
130+
"text": [
131+
"/usr/local/lib/python2.7/dist-packages/theano/misc/pycuda_init.py:34: UserWarning: PyCUDA import failed in theano.misc.pycuda_init\n",
132+
" warnings.warn(\"PyCUDA import failed in theano.misc.pycuda_init\")\n",
133+
"....................S..............."
134+
]
135+
},
136+
{
137+
"name": "stdout",
138+
"output_type": "stream",
139+
"text": [
140+
"Theano version 0.7.0.dev-54186290a97186b9c6b76317e007844529a352f4\n",
141+
"theano is installed in /usr/local/lib/python2.7/dist-packages/theano\n",
142+
"NumPy version 1.10.1\n",
143+
"NumPy relaxed strides checking option: True\n",
144+
"NumPy is installed in /usr/lib/python2.7/dist-packages/numpy\n",
145+
"Python version 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2]\n",
146+
"nose version 1.3.7\n"
147+
]
148+
},
149+
{
150+
"name": "stderr",
151+
"output_type": "stream",
152+
"text": [
153+
"\n",
154+
"----------------------------------------------------------------------\n",
155+
"Ran 37 tests in 37.919s\n",
156+
"\n",
157+
"OK (SKIP=1)\n"
158+
]
159+
},
160+
{
161+
"data": {
162+
"text/plain": [
163+
"<nose.result.TextTestResult run=37 errors=0 failures=0>"
164+
]
165+
},
166+
"execution_count": 3,
167+
"metadata": {},
168+
"output_type": "execute_result"
169+
}
170+
],
171+
"source": [
172+
"theano.test()"
173+
]
174+
},
175+
{
176+
"cell_type": "markdown",
177+
"metadata": {},
178+
"source": [
179+
"这里我已经在本地 `Windows` 配好了 `GPU` 的设置,如果没有配好,显示的结果可能不一样。\n",
180+
"\n",
181+
"`Windows` 下第一次运行可能会显示 `DEBUG: nvcc STDOUT` 等内容,**`Just ignore it!`**"
182+
]
183+
}
184+
],
185+
"metadata": {
186+
"kernelspec": {
187+
"display_name": "Python 2",
188+
"language": "python",
189+
"name": "python2"
190+
},
191+
"language_info": {
192+
"codemirror_mode": {
193+
"name": "ipython",
194+
"version": 2
195+
},
196+
"file_extension": ".py",
197+
"mimetype": "text/x-python",
198+
"name": "python",
199+
"nbconvert_exporter": "python",
200+
"pygments_lexer": "ipython2",
201+
"version": "2.7.6"
202+
}
203+
},
204+
"nbformat": 4,
205+
"nbformat_minor": 0
206+
}

09. theano/09.01 introduction and installation.ipynb.REMOVED.git-id

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
df42578b7bd3c7a9cea6ab49118537b543a60ec8
1+
c724d58f499a3332c788a91db5a4bc7888924179
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d00aaf25f64be888e5ce70962a07e9372126f5ba
1+
c5f58238f46e59e2c4256b9b0ad3c55eb3509cba
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e742f36bb55ffc69bcd84b3a7e8cb4d486a918a4
1+
b700b87c50e114ba229377e6248a2ba7591b9a11
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2a207a309f728f12e5f45faadafde766be259372

09. theano/download_mnist.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import os
2-
import os.path
3-
import urllib
4-
import gzip
5-
import shutil
6-
7-
if not os.path.exists('mnist'):
8-
os.mkdir('mnist')
9-
10-
def download_and_gzip(name):
11-
if not os.path.exists(name + '.gz'):
12-
urllib.urlretrieve('http://yann.lecun.com/exdb/' + name + '.gz', name + '.gz')
13-
if not os.path.exists(name):
14-
with gzip.open(name + '.gz', 'rb') as f_in, open(name, 'wb') as f_out:
15-
shutil.copyfileobj(f_in, f_out)
16-
17-
download_and_gzip('mnist/train-images-idx3-ubyte')
18-
download_and_gzip('mnist/train-labels-idx1-ubyte')
19-
download_and_gzip('mnist/t10k-images-idx3-ubyte')
1+
import os
2+
import os.path
3+
import urllib
4+
import gzip
5+
import shutil
6+
7+
if not os.path.exists('mnist'):
8+
os.mkdir('mnist')
9+
10+
def download_and_gzip(name):
11+
if not os.path.exists(name + '.gz'):
12+
urllib.urlretrieve('http://yann.lecun.com/exdb/' + name + '.gz', name + '.gz')
13+
if not os.path.exists(name):
14+
with gzip.open(name + '.gz', 'rb') as f_in, open(name, 'wb') as f_out:
15+
shutil.copyfileobj(f_in, f_out)
16+
17+
download_and_gzip('mnist/train-images-idx3-ubyte')
18+
download_and_gzip('mnist/train-labels-idx1-ubyte')
19+
download_and_gzip('mnist/t10k-images-idx3-ubyte')
2020
download_and_gzip('mnist/t10k-labels-idx1-ubyte')

09. theano/load.py

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
import numpy as np
2-
import os
3-
4-
datasets_dir = './'
5-
6-
def one_hot(x,n):
7-
if type(x) == list:
8-
x = np.array(x)
9-
x = x.flatten()
10-
o_h = np.zeros((len(x),n))
11-
o_h[np.arange(len(x)),x] = 1
12-
return o_h
13-
14-
def mnist(ntrain=60000,ntest=10000,onehot=True):
15-
data_dir = os.path.join(datasets_dir,'mnist/')
16-
fd = open(os.path.join(data_dir,'train-images-idx3-ubyte'))
17-
loaded = np.fromfile(file=fd,dtype=np.uint8)
18-
trX = loaded[16:].reshape((60000,28*28)).astype(float)
19-
20-
fd = open(os.path.join(data_dir,'train-labels-idx1-ubyte'))
21-
loaded = np.fromfile(file=fd,dtype=np.uint8)
22-
trY = loaded[8:].reshape((60000))
23-
24-
fd = open(os.path.join(data_dir,'t10k-images-idx3-ubyte'))
25-
loaded = np.fromfile(file=fd,dtype=np.uint8)
26-
teX = loaded[16:].reshape((10000,28*28)).astype(float)
27-
28-
fd = open(os.path.join(data_dir,'t10k-labels-idx1-ubyte'))
29-
loaded = np.fromfile(file=fd,dtype=np.uint8)
30-
teY = loaded[8:].reshape((10000))
31-
32-
trX = trX/255.
33-
teX = teX/255.
34-
35-
trX = trX[:ntrain]
36-
trY = trY[:ntrain]
37-
38-
teX = teX[:ntest]
39-
teY = teY[:ntest]
40-
41-
if onehot:
42-
trY = one_hot(trY, 10)
43-
teY = one_hot(teY, 10)
44-
else:
45-
trY = np.asarray(trY)
46-
teY = np.asarray(teY)
47-
1+
import numpy as np
2+
import os
3+
4+
datasets_dir = './'
5+
6+
def one_hot(x,n):
7+
if type(x) == list:
8+
x = np.array(x)
9+
x = x.flatten()
10+
o_h = np.zeros((len(x),n))
11+
o_h[np.arange(len(x)),x] = 1
12+
return o_h
13+
14+
def mnist(ntrain=60000,ntest=10000,onehot=True):
15+
data_dir = os.path.join(datasets_dir,'mnist/')
16+
fd = open(os.path.join(data_dir,'train-images-idx3-ubyte'))
17+
loaded = np.fromfile(file=fd,dtype=np.uint8)
18+
trX = loaded[16:].reshape((60000,28*28)).astype(float)
19+
20+
fd = open(os.path.join(data_dir,'train-labels-idx1-ubyte'))
21+
loaded = np.fromfile(file=fd,dtype=np.uint8)
22+
trY = loaded[8:].reshape((60000))
23+
24+
fd = open(os.path.join(data_dir,'t10k-images-idx3-ubyte'))
25+
loaded = np.fromfile(file=fd,dtype=np.uint8)
26+
teX = loaded[16:].reshape((10000,28*28)).astype(float)
27+
28+
fd = open(os.path.join(data_dir,'t10k-labels-idx1-ubyte'))
29+
loaded = np.fromfile(file=fd,dtype=np.uint8)
30+
teY = loaded[8:].reshape((10000))
31+
32+
trX = trX/255.
33+
teX = teX/255.
34+
35+
trX = trX[:ntrain]
36+
trY = trY[:ntrain]
37+
38+
teX = teX[:ntest]
39+
teY = teY[:ntest]
40+
41+
if onehot:
42+
trY = one_hot(trY, 10)
43+
teY = one_hot(teY, 10)
44+
else:
45+
trY = np.asarray(trY)
46+
teY = np.asarray(teY)
47+
4848
return trX,teX,trY,teY

0 commit comments

Comments
 (0)