def subset_iterator(X, m, repeats=1):
'''
Iterates over array X in chunks of m, repeat number of times.
Each time the order of the repeat is randomly generated.
'''
N, dim = X.shape
progress = tqdm(total=repeats * int(N / m))
for i in range(repeats):
indices = np.random.permutation(N)
for idx in np.array_split(indices, N // m):
yield X[idx][:]
progress.update()
progress.close()
评论列表
文章目录