forked from pjreddie/dl-hw0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trymnist.py
34 lines (27 loc) · 825 Bytes
/
trymnist.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
from uwnet import *
def softmax_model():
l = [make_connected_layer(784, 10, SOFTMAX)]
return make_net(l)
def neural_net():
l = [ make_connected_layer(784, 32, LRELU),
make_connected_layer(32, 10, SOFTMAX)]
return make_net(l)
print("loading data...")
train = load_image_classification_data("mnist/mnist.train", "mnist/mnist.labels")
test = load_image_classification_data("mnist/mnist.test", "mnist/mnist.labels")
print("done")
print
print("making model...")
batch = 128
iters = 5000
rate = .01
momentum = .9
decay = .0
m = softmax_model()
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))