Created
December 17, 2017 12:54
-
-
Save valpackett/5382d36c12bfe4516594e1084ace5e5a to your computer and use it in GitHub Desktop.
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 pad_or_trim(mat, required_len): | |
if mat.shape[0] < required_len: | |
return np.pad(mat, ((0, required_len - mat.shape[0]), (0, 0)), 'constant') | |
if mat.shape[0] > required_len: | |
return mat[:required_len] | |
return mat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment