I managed to get around it by using Minibatch.update_shared_f
:
def choice_iterator(size, nrows, seed):
state = np.random.RandomState()
state.seed(seed)
while True:
yield sorted(np.random.randint(0, nrows+1, size=size))
def update_shared_f_in_memory(obj, size, seed):
nrows = len(obj) if isinstance(obj, np.ndarray) else len(obj.index)
generator = choice_iterator(size=size, nrows=nrows, seed=seed)
def f():
where = next(generator)
return obj[where] if isinstance(obj, np.ndarray) else obj.iloc[where]
return f