(N=15)
| 2271 | |
| 2272 | |
| 2273 | def test_conv(N=15): |
| 2274 | np.random.seed(12345) |
| 2275 | N = np.inf if N is None else N |
| 2276 | i = 0 |
| 2277 | while i < N: |
| 2278 | n_ex = np.random.randint(2, 15) |
| 2279 | in_rows = np.random.randint(2, 15) |
| 2280 | in_cols = np.random.randint(2, 15) |
| 2281 | in_ch = np.random.randint(2, 15) |
| 2282 | out_ch = np.random.randint(2, 15) |
| 2283 | f_shape = ( |
| 2284 | min(in_rows, np.random.randint(2, 10)), |
| 2285 | min(in_cols, np.random.randint(2, 10)), |
| 2286 | ) |
| 2287 | s = np.random.randint(1, 3) |
| 2288 | p = np.random.randint(0, 5) |
| 2289 | |
| 2290 | X = np.random.rand(n_ex, in_rows, in_cols, in_ch) |
| 2291 | X_pad, p = pad2D(X, p) |
| 2292 | W = np.random.randn(f_shape[0], f_shape[1], in_ch, out_ch) |
| 2293 | |
| 2294 | gold = conv2D_naive(X, W, s, p) |
| 2295 | mine = conv2D(X, W, s, p) |
| 2296 | |
| 2297 | np.testing.assert_almost_equal(mine, gold) |
| 2298 | print("PASSED") |
| 2299 | i += 1 |
| 2300 | |
| 2301 | |
| 2302 | ####################################################################### |
nothing calls this directly
no test coverage detected