-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-linearization.py
41 lines (34 loc) · 1004 Bytes
/
test-linearization.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
import numpy as np
H = 5
W = 8
D = 4
x = np.random.rand(H, W, D)
xl = np.copy(x).reshape(-1)
print(x.shape)
print(xl.shape)
for h in range(H):
for w in range(W):
for d in range(D):
# check index calculation
index = h*W*D + w*D + d
print("h={}, w={}, d={}\t".format(h, w, d), end='')
if xl[index] == x[h, w, d]:
print("OK\t", end='')
else:
print("**** NOK ***\t", end='')
# check back calculation
back_d = index % D
if back_d == d:
print("OK\t", end='')
else:
print("**** NOK ***\t", end='')
back_h = index // (W*D)
if back_h == h:
print("OK\t", end='')
else:
print("**** NOK ***\t", end='')
back_w = (index // D) % W
if back_w == w:
print("OK\t")
else:
print("**** NOK ***\t")