forked from marcan/cl-waifu2x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
62 lines (56 loc) · 1.36 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import pyopencl as cl
import time, sys
from scipy import misc, signal
from PIL import Image
np.set_printoptions(precision=5, suppress=True)
from cl_simple import CLNN_Simple
from cl_runs import CLNN_Runs
ctx = cl.create_some_context()
model = [
{
"nInputPlane": 1,
"nOutputPlane": 2,
"kW": 3,
"kH": 3,
"bias": [0, 0],
"weight": [
[
[[1.0,0.0,0.0],
[0.0,0.0,0.0],
[0.0,0.0,0.0]],
],
[
[[2.0,0.0,0.0],
[0.0,0.0,0.0],
[0.0,0.0,0.0]],
],
],
},
{
"nInputPlane": 2,
"nOutputPlane": 1,
"kW": 3,
"kH": 3,
"bias": [100],
"weight": [
[
[[1.0000000,0.0000000,0.0000000],
[0.0000000,0.0000000,0.0000000],
[0.0000000,0.0000000,0.0000000]],
[[0.0010000,0.0000000,0.0000000],
[0.0000000,0.0000000,0.0000000],
[0.0000000,0.0000000,0.0000000]],
],
],
},
]
nn = CLNN_Runs(ctx, model)
bw, bh = nn.bw, nn.bh
blk = np.arange(bw*bh).reshape((bh,bw)).astype(np.float32)
print blk[:10,:10]
print
fblk = nn.filter_block(blk)
print fblk[:10,:10]