Skip to content

Commit 2ae7c75

Browse files
committed
Twiddling
1 parent 34ec420 commit 2ae7c75

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

src/conv.py

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"""
1111

1212
import network3
13-
from network3 import Network
13+
from network3 import sigmoid, tanh, ReLU, Network
1414
from network3 import ConvPoolLayer, FullyConnectedLayer, SoftmaxLayer
1515
training_data, validation_data, test_data = network3.load_data_shared()
1616
mini_batch_size = 10
@@ -44,17 +44,20 @@ def omit_FC():
4444
SoftmaxLayer(n_in=20*12*12, n_out=10)], mini_batch_size)
4545
net.SGD(training_data, 60, mini_batch_size, 0.1, validation_data, test_data)
4646

47-
def dbl_conv():
47+
def dbl_conv(activation_fn=sigmoid):
4848
for j in range(3):
4949
print "Conv + Conv + FC architecture"
5050
net = Network([
5151
ConvPoolLayer(image_shape=(mini_batch_size, 1, 28, 28),
5252
filter_shape=(20, 1, 5, 5),
53-
poolsize=(2, 2)),
53+
poolsize=(2, 2),
54+
activation_fn=activation_fn),
5455
ConvPoolLayer(image_shape=(mini_batch_size, 20, 12, 12),
5556
filter_shape=(40, 20, 5, 5),
56-
poolsize=(2, 2)),
57-
FullyConnectedLayer(n_in=40*4*4, n_out=100),
57+
poolsize=(2, 2),
58+
activation_fn=activation_fn),
59+
FullyConnectedLayer(
60+
n_in=40*4*4, n_out=100, activation_fn=activation_fn),
5861
SoftmaxLayer(n_in=100, n_out=10)], mini_batch_size)
5962
net.SGD(training_data, 60, mini_batch_size, 0.1, validation_data, test_data)
6063

@@ -73,24 +76,8 @@ def regularized_dbl_conv():
7376
SoftmaxLayer(n_in=100, n_out=10)], mini_batch_size)
7477
net.SGD(training_data, 60, mini_batch_size, 0.1, validation_data, test_data, lmbda=lmbda)
7578

76-
def dbl_conv_tanh():
77-
for j in range(3):
78-
print "Conv + Conv + FC, using tanh, trial %s" % j
79-
net = Network([
80-
ConvPoolLayer(image_shape=(mini_batch_size, 1, 28, 28),
81-
filter_shape=(20, 1, 5, 5),
82-
poolsize=(2, 2),
83-
activation_fn=tanh),
84-
ConvPoolLayer(image_shape=(mini_batch_size, 20, 12, 12),
85-
filter_shape=(40, 20, 5, 5),
86-
poolsize=(2, 2),
87-
activation_fn=tanh),
88-
FullyConnectedLayer(n_in=40*4*4, n_out=100, activation_fn=tanh),
89-
SoftmaxLayer(n_in=100, n_out=10)], mini_batch_size)
90-
net.SGD(training_data, 60, mini_batch_size, 0.1, validation_data, test_data)
91-
9279
def dbl_conv_relu():
93-
for lmbda in [0.00001, 0.0001, 0.001, 0.01, 0.1, 1.0, 10.0, 100.0]:
80+
for lmbda in [0.0, 0.00001, 0.0001, 0.001, 0.01, 0.1, 1.0, 10.0, 100.0]:
9481
for j in range(3):
9582
print "Conv + Conv + FC num %s, relu, with regularization %s" % (j, lmbda)
9683
net = Network([
@@ -126,5 +113,5 @@ def expanded_data():
126113
FullyConnectedLayer(n_in=40*4*4, n_out=100, activation_fn=ReLU),
127114
SoftmaxLayer(n_in=100, n_out=10)], mini_batch_size)
128115
net.SGD(expanded_training_data, 20, mini_batch_size, 0.03,
129-
validation_data, test_data, lmbda=1.0)
116+
validation_data, test_data, lmbda=0.1)
130117

0 commit comments

Comments
 (0)