froog 0.3.1__py3-none-any.whl → 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- froog/nn.py +3 -3
- froog/ops.py +1 -2
- froog/ops_gpu.py +2 -1
- froog/tensor.py +1 -1
- froog/utils.py +2 -1
- {froog-0.3.1.dist-info → froog-0.3.2.dist-info}/METADATA +1 -1
- froog-0.3.2.dist-info/RECORD +13 -0
- froog-0.3.1.dist-info/RECORD +0 -13
- {froog-0.3.1.dist-info → froog-0.3.2.dist-info}/LICENSE +0 -0
- {froog-0.3.1.dist-info → froog-0.3.2.dist-info}/WHEEL +0 -0
- {froog-0.3.1.dist-info → froog-0.3.2.dist-info}/top_level.txt +0 -0
froog/nn.py
CHANGED
@@ -10,8 +10,8 @@ from froog.tensor import Tensor
|
|
10
10
|
import numpy as np
|
11
11
|
|
12
12
|
def Linear(*x):
|
13
|
-
#
|
14
|
-
ret = np.random.uniform(-1., 1., size=x)/np.sqrt(np.prod(x))
|
13
|
+
# random Glorot initialization
|
14
|
+
ret = np.random.uniform(-1., 1., size=x)/np.sqrt(np.prod(x))
|
15
15
|
return ret.astype(np.float32)
|
16
16
|
|
17
17
|
def swish(x):
|
@@ -55,6 +55,6 @@ class BatchNorm2D:
|
|
55
55
|
def __call__(self, x):
|
56
56
|
x = x.sub(self.running_mean.reshape(shape=[1, -1, 1, 1]))
|
57
57
|
x = x.mul(self.weight.reshape(shape=[1, -1, 1, 1]))
|
58
|
-
x = x.div(self.running_var.add(Tensor([self.eps], gpu=x.gpu)).reshape(shape=[1, -1, 1, 1]).sqrt())
|
58
|
+
x = x.div(self.running_var.add(Tensor([self.eps], gpu=x.gpu)).reshape(shape=[1, -1, 1, 1]).sqrt())
|
59
59
|
x = x.add(self.bias.reshape(shape=[1, -1, 1, 1]))
|
60
60
|
return x
|
froog/ops.py
CHANGED
@@ -340,7 +340,6 @@ class MaxPool2D(Function):
|
|
340
340
|
*ctx.kernel_size)
|
341
341
|
register('max_pool2d', MaxPool2D)
|
342
342
|
|
343
|
-
|
344
343
|
class AvgPool2D(Function):
|
345
344
|
@staticmethod
|
346
345
|
def forward(ctx, x, kernel_size=(2,2)):
|
@@ -351,7 +350,7 @@ class AvgPool2D(Function):
|
|
351
350
|
@staticmethod
|
352
351
|
def backward(ctx, grad_output):
|
353
352
|
s, = ctx.saved_tensors
|
354
|
-
py, px = ctx.kernel_size #
|
353
|
+
py, px = ctx.kernel_size # kernel_size passed from forward context
|
355
354
|
my, mx = (s[2]//py)*py, (s[3]//px)*px
|
356
355
|
ret = np.zeros(s, dtype=grad_output.dtype)
|
357
356
|
for Y in range(py):
|
froog/ops_gpu.py
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
# | ___|| __ || |_| || |_| || || |
|
6
6
|
# | | | | | || || || |_| |
|
7
7
|
# |___| |___| |_||_______||_______||_______|
|
8
|
+
#
|
9
|
+
# OpenCL kernels
|
8
10
|
|
9
11
|
import numpy as np
|
10
12
|
from .tensor import Function, register
|
@@ -71,7 +73,6 @@ def unary_op(ctx, code, x):
|
|
71
73
|
prg.unop(ctx.cl_queue, [np.prod(ret.shape)], None, x, ret)
|
72
74
|
return ret
|
73
75
|
|
74
|
-
# ???
|
75
76
|
@functools.lru_cache
|
76
77
|
def cl_pooling_krnl_build(cl_ctx, iter_op, result_op, init_val=0):
|
77
78
|
prg = """
|
froog/tensor.py
CHANGED
froog/utils.py
CHANGED
@@ -67,7 +67,8 @@ def im2col(x, H, W):
|
|
67
67
|
tx = x.reshape(bs, -1)[:, idx]
|
68
68
|
|
69
69
|
# all the time is spent here
|
70
|
-
|
70
|
+
# np.ravel() flattens the array into a 1-dimensional shape
|
71
|
+
tx = tx.ravel()
|
71
72
|
return tx.reshape(-1, cin*W*H)
|
72
73
|
|
73
74
|
def col2im(tx, H, W, OY, OX):
|
@@ -0,0 +1,13 @@
|
|
1
|
+
froog/__init__.py,sha256=Mzxgj9bA2G4kcmbmY8fY0KCKgimPucn3hTVRWBJ-5_Q,57
|
2
|
+
froog/gradcheck.py,sha256=HlA0VDKE-c44o0E73QsUTIVoNs-w_C9FyKFlHfoagIQ,2415
|
3
|
+
froog/nn.py,sha256=_5dzIoxz1L4yEnYfONVc8xIs8vqRpUBBwZwHLvBu9yY,2023
|
4
|
+
froog/ops.py,sha256=t0P0OzzlhYBgAhM3urLsXLl9LJNff_7Yiyc_pYgP5B4,14388
|
5
|
+
froog/ops_gpu.py,sha256=CJ-kXvY3TS1lHOBOhR3IlMnZMLtrOEAeM78rTnk-lIc,15482
|
6
|
+
froog/optim.py,sha256=m8Q1xe3WwU41obGSMVjRMIs3rWqfqRWfhlbhF9oJyWA,2450
|
7
|
+
froog/tensor.py,sha256=Wix4pE5-OIY8Pvv3bqNCSU_-c_wZV2HrmAtBwMPmAfE,7636
|
8
|
+
froog/utils.py,sha256=vs9bmBOyfy0_NR8jPl2DMWBCAqIacJ6a75Lbso2MAKs,3347
|
9
|
+
froog-0.3.2.dist-info/LICENSE,sha256=k_856uNmcNUoLC_HkI18c1WomqvQ1Ioqk6gwYfWQiaM,31
|
10
|
+
froog-0.3.2.dist-info/METADATA,sha256=mjq5LtJXs29JzF-_cLLDTaGnczJ15RucQityVAyNzCE,13898
|
11
|
+
froog-0.3.2.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
12
|
+
froog-0.3.2.dist-info/top_level.txt,sha256=XPz35C_JWu20LlsVxIMdMZn8DD58Ak78LwgWFBGYZwY,6
|
13
|
+
froog-0.3.2.dist-info/RECORD,,
|
froog-0.3.1.dist-info/RECORD
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
froog/__init__.py,sha256=Mzxgj9bA2G4kcmbmY8fY0KCKgimPucn3hTVRWBJ-5_Q,57
|
2
|
-
froog/gradcheck.py,sha256=HlA0VDKE-c44o0E73QsUTIVoNs-w_C9FyKFlHfoagIQ,2415
|
3
|
-
froog/nn.py,sha256=VeUpmjrv1XrH786GEOc9ruzDAHULiVHKpDtn187EQgI,2076
|
4
|
-
froog/ops.py,sha256=PEXZb3lNeYwFpRfcEvEs-KLB4rQqHHUdraR1qOgw5Zs,14389
|
5
|
-
froog/ops_gpu.py,sha256=bQ2bzMqmvY2xLEaTjOIXN3KOb-7yZEDjmliV8tWlC6g,15469
|
6
|
-
froog/optim.py,sha256=m8Q1xe3WwU41obGSMVjRMIs3rWqfqRWfhlbhF9oJyWA,2450
|
7
|
-
froog/tensor.py,sha256=Dacd2UQVfl7RsjADjrhBO1rMVcDVaeJuI55sFfxonhk,7685
|
8
|
-
froog/utils.py,sha256=zWquIwvOUBfCzaoA7eAOov7C5NbGxus5RXx9JPM1jeg,3325
|
9
|
-
froog-0.3.1.dist-info/LICENSE,sha256=k_856uNmcNUoLC_HkI18c1WomqvQ1Ioqk6gwYfWQiaM,31
|
10
|
-
froog-0.3.1.dist-info/METADATA,sha256=3whhO1sbqWZQpXBywz9ypN7iLpR-n82qpZPEjv0of_s,13898
|
11
|
-
froog-0.3.1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
12
|
-
froog-0.3.1.dist-info/top_level.txt,sha256=XPz35C_JWu20LlsVxIMdMZn8DD58Ak78LwgWFBGYZwY,6
|
13
|
-
froog-0.3.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|