Created
August 15, 2019 22:00
-
-
Save bmcfee/9f079cd2f70da801d62d7e8213c50e41 to your computer and use it in GitHub Desktop.
In-place patching (framing of 2d inputs)
This file contains 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 frame2d(x, patch_length, hop_length): | |
n_frames = 1 + (x.shape[-1] - patch_length) // hop_length | |
x_frame = np.lib.stride_tricks.as_strided(x, shape=(x.shape[0], patch_length, n_frames), | |
strides=(1 * x.itemsize, x.shape[0] * x.itemsize, hop_length * x.shape[0] * x.itemsize)) | |
return x_frame |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment