2020-10-19 21:08:55

This commit is contained in:
wizardforcel
2020-10-19 21:08:55 +08:00
parent 7f63048035
commit ab0caba1f0
140 changed files with 3982 additions and 3982 deletions

View File

@@ -2,7 +2,7 @@
In [1]:
```
```py
import theano
import theano.tensor as T
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
@@ -13,7 +13,7 @@ srng = RandomStreams()
```
```
```py
Using gpu device 1: Tesla C2075 (CNMeM is disabled)
```
@@ -22,7 +22,7 @@ Using gpu device 1: Tesla C2075 (CNMeM is disabled)
In [2]:
```
```py
def floatX(X):
return np.asarray(X, dtype=theano.config.floatX)
@@ -61,7 +61,7 @@ def RMSprop(cost, params, lr=0.001, rho=0.9, epsilon=1e-6):
In [3]:
```
```py
from theano.tensor.nnet.conv import conv2d
from theano.tensor.signal.downsample import max_pool_2d
@@ -81,7 +81,7 @@ from theano.tensor.signal.downsample import max_pool_2d
In [4]:
```
```py
trX, teX, trY, teY = mnist(onehot=True)
trX = trX.reshape(-1, 1, 28, 28)
@@ -95,7 +95,7 @@ teX = teX.reshape(-1, 1, 28, 28)
In [5]:
```
```py
def model(X, w, w2, w3, w4, p_drop_conv, p_drop_hidden):
# X: 128 * 1 * 28 * 28
@@ -149,7 +149,7 @@ def model(X, w, w2, w3, w4, p_drop_conv, p_drop_hidden):
In [6]:
```
```py
X = T.ftensor4()
Y = T.fmatrix()
@@ -165,7 +165,7 @@ w_o = init_weights((625, 10))
In [7]:
```
```py
noise_l1, noise_l2, noise_l3, noise_l4, noise_py_x = model(X, w, w2, w3, w4, 0.2, 0.5)
```
@@ -174,7 +174,7 @@ noise_l1, noise_l2, noise_l3, noise_l4, noise_py_x = model(X, w, w2, w3, w4, 0.2
In [8]:
```
```py
l1, l2, l3, l4, py_x = model(X, w, w2, w3, w4, 0., 0.)
y_x = T.argmax(py_x, axis=1)
@@ -184,7 +184,7 @@ y_x = T.argmax(py_x, axis=1)
In [9]:
```
```py
cost = T.mean(T.nnet.categorical_crossentropy(noise_py_x, Y))
params = [w, w2, w3, w4, w_o]
updates = RMSprop(cost, params, lr=0.001)
@@ -195,7 +195,7 @@ updates = RMSprop(cost, params, lr=0.001)
In [10]:
```
```py
train = theano.function(inputs=[X, Y], outputs=cost, updates=updates, allow_input_downcast=True)
predict = theano.function(inputs=[X], outputs=y_x, allow_input_downcast=True)
@@ -206,7 +206,7 @@ for i in range(50):
```
```
```py
iter 001, 0.917
iter 002, 0.974
iter 003, 0.983