Commit 4e8ab1ef343355a45dfe59c92d605d3e2c849004
1 parent
4eac6680
Exists in
master
and in
1 other branch
staged.
Showing
1 changed file
with
8 additions
and
8 deletions
Show diff stats
mmodel/theano/THEANO.py
@@ -48,7 +48,7 @@ class ModelTHEANO(ModelBase): | @@ -48,7 +48,7 @@ class ModelTHEANO(ModelBase): | ||
48 | X_train, X_test, Y_train, Y_test = cross_validation.train_test_split(X, Y, test_size=0.2, random_state=0) | 48 | X_train, X_test, Y_train, Y_test = cross_validation.train_test_split(X, Y, test_size=0.2, random_state=0) |
49 | 49 | ||
50 | train_set_x, train_set_y = shared_dataset((X_train, Y_train)) | 50 | train_set_x, train_set_y = shared_dataset((X_train, Y_train)) |
51 | - valid_set_x, valid_set_y = train_set_x[:1000], train_set_y[:1000] | 51 | + valid_set_x, valid_set_y = shared_dataset((X_train[:1000], Y_train[:1000])) |
52 | test_set_x, test_set_y = shared_dataset((X_test, Y_test)) | 52 | test_set_x, test_set_y = shared_dataset((X_test, Y_test)) |
53 | 53 | ||
54 | # compute number of minibatches for training, validation and testing | 54 | # compute number of minibatches for training, validation and testing |
@@ -89,8 +89,8 @@ class ModelTHEANO(ModelBase): | @@ -89,8 +89,8 @@ class ModelTHEANO(ModelBase): | ||
89 | 89 | ||
90 | # Construct the second convolutional pooling layer | 90 | # Construct the second convolutional pooling layer |
91 | # filtering reduces the image size to (148-5+1, 148-5+1) = (144, 144) | 91 | # filtering reduces the image size to (148-5+1, 148-5+1) = (144, 144) |
92 | - # maxpooling reduces this further to (144/4, 144/4) = (38, 38) | ||
93 | - # 4D output tensor is thus of shape (batch_size, nkerns[1], 38, 38) | 92 | + # maxpooling reduces this further to (144/4, 144/4) = (36, 36) |
93 | + # 4D output tensor is thus of shape (batch_size, nkerns[1], 36, 36) | ||
94 | layer1 = ConvPoolLayer( | 94 | layer1 = ConvPoolLayer( |
95 | rng, | 95 | rng, |
96 | input=layer0.output, | 96 | input=layer0.output, |
@@ -101,15 +101,15 @@ class ModelTHEANO(ModelBase): | @@ -101,15 +101,15 @@ class ModelTHEANO(ModelBase): | ||
101 | 101 | ||
102 | # the HiddenLayer being fully-connected, it operates on 2D matrices of | 102 | # the HiddenLayer being fully-connected, it operates on 2D matrices of |
103 | # shape (batch_size, num_pixels) (i.e matrix of rasterized images). | 103 | # shape (batch_size, num_pixels) (i.e matrix of rasterized images). |
104 | - # This will generate a matrix of shape (batch_size, nkerns[1] * 4 * 4), | ||
105 | - # or (500, 50 * 4 * 4) = (500, 800) with the default values. | 104 | + # This will generate a matrix of shape (batch_size, nkerns[1] * 36 * 36), |
105 | + # or (500, 50 * 36 * 36) = (500, 800) with the default values. | ||
106 | layer2_input = layer1.output.flatten(2) | 106 | layer2_input = layer1.output.flatten(2) |
107 | 107 | ||
108 | # construct a fully-connected sigmoidal layer | 108 | # construct a fully-connected sigmoidal layer |
109 | layer2 = HiddenLayer( | 109 | layer2 = HiddenLayer( |
110 | rng, | 110 | rng, |
111 | input=layer2_input, | 111 | input=layer2_input, |
112 | - n_in=nkerns[1] * 38 * 38, | 112 | + n_in=nkerns[1] * 36 * 36, |
113 | n_out=500, | 113 | n_out=500, |
114 | activation=T.tanh | 114 | activation=T.tanh |
115 | ) | 115 | ) |
@@ -156,8 +156,8 @@ class ModelTHEANO(ModelBase): | @@ -156,8 +156,8 @@ class ModelTHEANO(ModelBase): | ||
156 | ] | 156 | ] |
157 | """ | 157 | """ |
158 | Total Parameters: | 158 | Total Parameters: |
159 | - >>> 20 * 64 + 1000 * 25 + 50 * 38 * 38 * 500 + 500 * 2 | ||
160 | - 36127280 | 159 | + >>> 20 * 64 + 1000 * 25 + 50 * 36 * 36 * 500 + 500 * 2 |
160 | + 32427280 | ||
161 | """ | 161 | """ |
162 | train_model = theano.function( | 162 | train_model = theano.function( |
163 | [index], | 163 | [index], |