-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
65 lines (48 loc) · 2.05 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from main import *
def test_my_images(images: np.ndarray):
"""
:param images: images drawn by myself
"""
assert images.shape[1] == 784, images.shape
_, network = get_network("backward_network")
proc = BackwardProcessor((784, 64, 16, 10), {}, network)
print(predict(proc, images / 255))
def test_default_images(row: int, column: int, start: int = 0):
data_load = DataLoader("resource")
data = data_load.resource
count, network = get_network("backward_network")
proc = BackwardProcessor((784, 64, 16, 10), data, network)
proc.load("t10k-images", "t10k-labels")
proc.input(start, start + row * column)
print(proc.predict().argmax(axis=1).reshape(column, row).T)
data_load.display_images(row, column)
def forward_test():
data = DataLoader("resource").resource
count, network = get_network("networks")
proc = Processor((784, 64, 16, 10), data, network)
print("t10k")
proc.load("t10k-images", "t10k-labels")
proc.input(0, 10000)
Recorder.less_output(proc.predict().argmax(axis=1) == proc.input_labels,
proc.loss(proc.predict()))
print("train")
proc.load("train-images", "train-labels")
proc.input(0, 60000)
Recorder.less_output(proc.predict().argmax(axis=1) == proc.input_labels,
proc.loss(proc.predict()))
def backward_test():
data = DataLoader("resource").resource
count, network = get_network("backward_network")
proc = BackwardProcessor((784, 64, 16, 10), data, network)
print("t10k")
proc.load("t10k-images", "t10k-labels")
proc.input(0, 10000)
Recorder.less_output(proc.predict().argmax(axis=1) == proc.input_labels,
proc.loss(proc.predict()))
print("train")
proc.load("train-images", "train-labels")
proc.input(0, 60000)
Recorder.less_output(proc.predict().argmax(axis=1) == proc.input_labels,
proc.loss(proc.predict()))