Last active
December 13, 2019 10:07
-
-
Save anirudhshenoy/d4e4228ebb884066efd65299f1d169cb to your computer and use it in GitHub Desktop.
Naive Implementation of Im2Col
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def im2col(x, kernel): | |
| kernel_shape = kernel.shape[0] | |
| rows = [] | |
| # Assuming Padding = 0, stride = 1 | |
| for row in range(x.shape[0] - 1): | |
| for col in range(x.shape[1] - 1): | |
| window = x[row: row + kernel_shape, col: col + kernel_shape] | |
| rows.append(window.flatten()) | |
| return np.transpose(np.array(rows)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment