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

Function convolve_flatten

cnn_class/edge_benchmark.py:34–47  ·  view source on GitHub ↗
(X)

Source from the content-addressed store, hash-verified

32
33
34def convolve_flatten(X):
35 # input will be (32, 32, 3, N)
36 # output will be (N, 32*32)
37 N = X.shape[-1]
38 flat = np.zeros((N, 32*32))
39 for i in range(N):
40 #flat[i] = X[:,:,:,i].reshape(3072)
41 bw = X[:,:,:,i].mean(axis=2) # make it grayscale
42 Gx = convolve2d(bw, Hx, mode='same')
43 Gy = convolve2d(bw, Hy, mode='same')
44 G = np.sqrt(Gx*Gx + Gy*Gy)
45 G /= G.max() # normalize it
46 flat[i] = G.reshape(32*32)
47 return flat
48
49
50def main():

Callers 1

mainFunction · 0.85

Calls 1

convolve2dFunction · 0.85

Tested by

no test coverage detected