MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / convolve2d

Function convolve2d

cnn_class/custom_blur.py:40–49  ·  view source on GitHub ↗
(X, W)

Source from the content-addressed store, hash-verified

38
39# same size as input
40def convolve2d(X, W):
41 n1, n2 = X.shape
42 m1, m2 = W.shape
43 Y = np.zeros((n1 + m1 - 1, n2 + m2 - 1))
44 for i in range(n1):
45 for j in range(n2):
46 Y[i:i+m1,j:j+m2] += X[i,j]*W
47 ret = Y[m1//2:-m1//2+1,m2//2:-m2//2+1]
48 assert(ret.shape == X.shape)
49 return ret
50
51# smaller than input
52# def convolve2d(X, W):

Callers 4

edge.pyFile · 0.85
blur.pyFile · 0.85
custom_blur.pyFile · 0.85
convolve_flattenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected