forked from illinois-impact/ece408_project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
m1.2.py
33 lines (26 loc) · 868 Bytes
/
m1.2.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
#!/usr/bin/env python
import mxnet as mx
import logging
from reader import load_mnist
# Log to stdout for MXNet
logging.getLogger().setLevel(logging.DEBUG) # logging to stdout
print "Loading fashion-mnist data...",
test_images, test_labels = load_mnist(
path="/fashion-mnist", rows=48, cols=48, kind="t10k-48")
print "done"
# Do everything in a single batch
batch_size = len(test_images)
# Get iterators that cover the dataset
test_iter = mx.io.NDArrayIter(
test_images, test_labels, batch_size)
# Evaluate the network
print "Loading model...",
lenet_model = mx.mod.Module.load(
prefix='/models/baseline', epoch=2, context=mx.gpu())
lenet_model.bind(data_shapes=test_iter.provide_data,
label_shapes=test_iter.provide_label)
print "done"
print "New Inference"
acc = mx.metric.Accuracy()
lenet_model.score(test_iter, acc)
print(acc)