Skip to content

Instantly share code, notes, and snippets.

@syaffers
Last active March 21, 2020 16:48
Show Gist options
  • Select an option

  • Save syaffers/0e483c4a8f78d34f596ece683ba06800 to your computer and use it in GitHub Desktop.

Select an option

Save syaffers/0e483c4a8f78d34f596ece683ba06800 to your computer and use it in GitHub Desktop.
Looped window extraction from numpy matrix
def extract_windows(array, clearing_time_index, max_time, sub_window_size):
examples = []
start = clearing_time_index + 1 - sub_window_size + 1
for i in range(max_time+1):
example = array[start+i:start+sub_window_size+i]
examples.append(np.expand_dims(example, 0))
return np.vstack(examples)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment