forked from oduerr/dl_tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.py
42 lines (38 loc) · 1.24 KB
/
Test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
__author__ = 'oli'
import cPickle as pickle
import gzip
with gzip.open('mnist_4000.pkl.gz', 'rb') as f:
(X,y) = pickle.load(f)
PIXELS = len(X[0,0,0,:])
X.shape, y.shape, PIXELS
from lasagne import layers
from lasagne import nonlinearities
from nolearn.lasagne import NeuralNet
net1 = NeuralNet(
# Geometry of the network
layers=[
('input', layers.InputLayer),
('conv1', layers.Conv2DLayer),
('pool1', layers.MaxPool2DLayer),
('conv2', layers.Conv2DLayer),
('pool2', layers.MaxPool2DLayer),
('hidden4', layers.DenseLayer),
('output', layers.DenseLayer),
],
input_shape=(None, 1, PIXELS, PIXELS), #None in the first axis indicates that the batch size can be set later
conv1_num_filters=32, conv1_filter_size=(3, 3), pool1_ds=(2, 2),
conv2_num_filters=64, conv2_filter_size=(2, 2), pool2_ds=(2, 2),
hidden4_num_units=500,
output_num_units=10, output_nonlinearity=nonlinearities.softmax,
# learning rate parameters
update_learning_rate=0.01,
update_momentum=0.9,
regression=False,
# We only train for 10 epochs
max_epochs=2,
verbose=1,
# Training test-set split
eval_size = 0.2
)
net = net1.fit(X[0:1000,:,:,:],y[0:1000])
print("Hallo")