-
Notifications
You must be signed in to change notification settings - Fork 40
/
tryhw1.py
47 lines (40 loc) · 1.51 KB
/
tryhw1.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
43
44
45
46
from uwnet import *
def conv_net():
l = [ make_convolutional_layer(32, 32, 3, 8, 3, 1),
make_activation_layer(RELU),
make_maxpool_layer(32, 32, 8, 3, 2),
make_convolutional_layer(16, 16, 8, 16, 3, 1),
make_activation_layer(RELU),
make_maxpool_layer(16, 16, 16, 3, 2),
make_convolutional_layer(8, 8, 16, 32, 3, 1),
make_activation_layer(RELU),
make_maxpool_layer(8, 8, 32, 3, 2),
make_convolutional_layer(4, 4, 32, 64, 3, 1),
make_activation_layer(RELU),
make_maxpool_layer(4, 4, 64, 3, 2),
make_connected_layer(256, 10),
make_activation_layer(SOFTMAX)]
return make_net(l)
print("loading data...")
train = load_image_classification_data("cifar/cifar.train", "cifar/cifar.labels")
test = load_image_classification_data("cifar/cifar.test", "cifar/cifar.labels")
print("done")
print
print("making model...")
batch = 128
iters = 5000
rate = .01
momentum = .9
decay = .005
m = conv_net()
print("training...")
train_image_classifier(m, train, batch, iters, rate, momentum, decay)
print("done")
print
print("evaluating model...")
print("training accuracy: %f", accuracy_net(m, train))
print("test accuracy: %f", accuracy_net(m, test))
# How accurate is the fully connected network vs the convnet when they use similar number of operations?
# Why are you seeing these results? Speculate based on the information you've gathered and what you know about DL and ML.
# Your answer:
#