Skip to content

Instantly share code, notes, and snippets.

@andykitchen
Created October 19, 2015 11:53
Show Gist options
  • Save andykitchen/0aecd5d30b20c5c64ec6 to your computer and use it in GitHub Desktop.
Save andykitchen/0aecd5d30b20c5c64ec6 to your computer and use it in GitHub Desktop.
w = 96
n = 20000
l = 32
def rand_ranges(a, b, l, size):
r = np.repeat(np.arange(l, dtype=np.intp)[np.newaxis], size, axis=0)
r += np.random.randint(a, b-l, size=size)[:,np.newaxis]
return r
si0 = np.random.randint(0, images.shape[0], size=n)
si1 = rand_ranges(0, w, l, size=n);
si2 = rand_ranges(0, w, l, size=n);
i5 = (
si0.reshape(n, 1, 1),
si1.reshape(n, l, 1),
si2.reshape(n, 1, l)
)
patches = zca_images[i5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment