Skip to content

Commit

Permalink
添加了静态的 HTML 文件
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lijin-THU committed Jan 6, 2016
1 parent 352e995 commit 56cc225
Show file tree
Hide file tree
Showing 134 changed files with 536 additions and 75 deletions.
2 changes: 1 addition & 1 deletion 03. numpy/03.04 array types.ipynb.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
713ccb0c837d616e4f75cc49a117c2297179862b
8b3a5b7d7391ea7f4735ef7a7f28a6bb4197e215
206 changes: 206 additions & 0 deletions 09. theano/09.01 introduction and installation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Theano 简介及其安装"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 简介"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`Theano` 是一个 `Python` 科学计算库,允许我们进行符号运算,并在 `CPU` 和 `GPU` 上执行。\n",
"\n",
"它最初由 `Montreal` 大学的机器学习研究者们所开发,用来进行机器学习的计算。\n",
"\n",
"按照[官网](http://deeplearning.net/software/theano/)上的说明,它拥有以下几个方面的特点:\n",
"\n",
"- 与 **Numpy, Scipy** 的紧密结合\n",
"- **GPU** 加速\n",
"- 高效的符号计算\n",
"- 速度和稳定性\n",
"- 动态生成 **C** 代码"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 使用 anaconda 安装 theano"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`windows` 下,使用 `anaconda` 安装 `theano` 的命令为:\n",
"\n",
" conda install mingw libpython\n",
" pip install theano\n",
" \n",
"`linux` 下,使用 `anaconda` 安装的命令为\n",
" \n",
" conda install theano\n",
"\n",
"安装好之后,还需要安装 `Cuda` 并进行 `GPU` 环境的配置,否则是不能利用 `GPU` 进行计算的,推荐使用 `linux/mac` 进行配置,具体方法可以参考[官网](http://deeplearning.net/software/theano/)上的配置说明。\n",
"\n",
"查看安装的版本:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"'0.7.0.dev-54186290a97186b9c6b76317e007844529a352f4'"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import theano\n",
"\n",
"theano.__version__"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"查看当前使用的 device:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'cpu'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"theano.config.device"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"运行测试:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/lib/python2.7/dist-packages/theano/misc/pycuda_init.py:34: UserWarning: PyCUDA import failed in theano.misc.pycuda_init\n",
" warnings.warn(\"PyCUDA import failed in theano.misc.pycuda_init\")\n",
"....................S..............."
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Theano version 0.7.0.dev-54186290a97186b9c6b76317e007844529a352f4\n",
"theano is installed in /usr/local/lib/python2.7/dist-packages/theano\n",
"NumPy version 1.10.1\n",
"NumPy relaxed strides checking option: True\n",
"NumPy is installed in /usr/lib/python2.7/dist-packages/numpy\n",
"Python version 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2]\n",
"nose version 1.3.7\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n",
"----------------------------------------------------------------------\n",
"Ran 37 tests in 37.919s\n",
"\n",
"OK (SKIP=1)\n"
]
},
{
"data": {
"text/plain": [
"<nose.result.TextTestResult run=37 errors=0 failures=0>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"theano.test()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"这里我已经在本地 `Windows` 配好了 `GPU` 的设置,如果没有配好,显示的结果可能不一样。\n",
"\n",
"`Windows` 下第一次运行可能会显示 `DEBUG: nvcc STDOUT` 等内容,**`Just ignore it!`**"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

This file was deleted.

2 changes: 1 addition & 1 deletion 09. theano/09.02 theano basics.ipynb.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
df42578b7bd3c7a9cea6ab49118537b543a60ec8
c724d58f499a3332c788a91db5a4bc7888924179
2 changes: 1 addition & 1 deletion 09. theano/09.03 gpu on windows.ipynb.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d00aaf25f64be888e5ce70962a07e9372126f5ba
c5f58238f46e59e2c4256b9b0ad3c55eb3509cba
2 changes: 1 addition & 1 deletion 09. theano/09.07 softmax on mnist.ipynb.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e742f36bb55ffc69bcd84b3a7e8cb4d486a918a4
b700b87c50e114ba229377e6248a2ba7591b9a11
1 change: 1 addition & 0 deletions 09. theano/09.08 net.ipynb.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2a207a309f728f12e5f45faadafde766be259372
38 changes: 19 additions & 19 deletions 09. theano/download_mnist.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import os
import os.path
import urllib
import gzip
import shutil

if not os.path.exists('mnist'):
os.mkdir('mnist')

def download_and_gzip(name):
if not os.path.exists(name + '.gz'):
urllib.urlretrieve('http://yann.lecun.com/exdb/' + name + '.gz', name + '.gz')
if not os.path.exists(name):
with gzip.open(name + '.gz', 'rb') as f_in, open(name, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)

download_and_gzip('mnist/train-images-idx3-ubyte')
download_and_gzip('mnist/train-labels-idx1-ubyte')
download_and_gzip('mnist/t10k-images-idx3-ubyte')
import os
import os.path
import urllib
import gzip
import shutil

if not os.path.exists('mnist'):
os.mkdir('mnist')

def download_and_gzip(name):
if not os.path.exists(name + '.gz'):
urllib.urlretrieve('http://yann.lecun.com/exdb/' + name + '.gz', name + '.gz')
if not os.path.exists(name):
with gzip.open(name + '.gz', 'rb') as f_in, open(name, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)

download_and_gzip('mnist/train-images-idx3-ubyte')
download_and_gzip('mnist/train-labels-idx1-ubyte')
download_and_gzip('mnist/t10k-images-idx3-ubyte')
download_and_gzip('mnist/t10k-labels-idx1-ubyte')
94 changes: 47 additions & 47 deletions 09. theano/load.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
import numpy as np
import os

datasets_dir = './'

def one_hot(x,n):
if type(x) == list:
x = np.array(x)
x = x.flatten()
o_h = np.zeros((len(x),n))
o_h[np.arange(len(x)),x] = 1
return o_h

def mnist(ntrain=60000,ntest=10000,onehot=True):
data_dir = os.path.join(datasets_dir,'mnist/')
fd = open(os.path.join(data_dir,'train-images-idx3-ubyte'))
loaded = np.fromfile(file=fd,dtype=np.uint8)
trX = loaded[16:].reshape((60000,28*28)).astype(float)

fd = open(os.path.join(data_dir,'train-labels-idx1-ubyte'))
loaded = np.fromfile(file=fd,dtype=np.uint8)
trY = loaded[8:].reshape((60000))

fd = open(os.path.join(data_dir,'t10k-images-idx3-ubyte'))
loaded = np.fromfile(file=fd,dtype=np.uint8)
teX = loaded[16:].reshape((10000,28*28)).astype(float)

fd = open(os.path.join(data_dir,'t10k-labels-idx1-ubyte'))
loaded = np.fromfile(file=fd,dtype=np.uint8)
teY = loaded[8:].reshape((10000))

trX = trX/255.
teX = teX/255.

trX = trX[:ntrain]
trY = trY[:ntrain]

teX = teX[:ntest]
teY = teY[:ntest]

if onehot:
trY = one_hot(trY, 10)
teY = one_hot(teY, 10)
else:
trY = np.asarray(trY)
teY = np.asarray(teY)

import numpy as np
import os

datasets_dir = './'

def one_hot(x,n):
if type(x) == list:
x = np.array(x)
x = x.flatten()
o_h = np.zeros((len(x),n))
o_h[np.arange(len(x)),x] = 1
return o_h

def mnist(ntrain=60000,ntest=10000,onehot=True):
data_dir = os.path.join(datasets_dir,'mnist/')
fd = open(os.path.join(data_dir,'train-images-idx3-ubyte'))
loaded = np.fromfile(file=fd,dtype=np.uint8)
trX = loaded[16:].reshape((60000,28*28)).astype(float)

fd = open(os.path.join(data_dir,'train-labels-idx1-ubyte'))
loaded = np.fromfile(file=fd,dtype=np.uint8)
trY = loaded[8:].reshape((60000))

fd = open(os.path.join(data_dir,'t10k-images-idx3-ubyte'))
loaded = np.fromfile(file=fd,dtype=np.uint8)
teX = loaded[16:].reshape((10000,28*28)).astype(float)

fd = open(os.path.join(data_dir,'t10k-labels-idx1-ubyte'))
loaded = np.fromfile(file=fd,dtype=np.uint8)
teY = loaded[8:].reshape((10000))

trX = trX/255.
teX = teX/255.

trX = trX[:ntrain]
trY = trY[:ntrain]

teX = teX[:ntest]
teY = teY[:ntest]

if onehot:
trY = one_hot(trY, 10)
teY = one_hot(teY, 10)
else:
trY = np.asarray(trY)
teY = np.asarray(teY)

return trX,teX,trY,teY
Loading

0 comments on commit 56cc225

Please sign in to comment.