Using numpy `as_strided` function to create patches, tiles, rolling or sliding windows of arbitrary dimension

EDIT JAN 2020: Changed the iterable return from a list to a generator to save memory. EDIT OCT 2020: Put the generator in a separate function, since mixing generators and return statements doesn’t work intiutively. Here’s the recipe I have so far: def window_nd(a, window, steps = None, axis = None, gen_data = False): “”” … Read more