(data, batch_size, seed)
data is a dict := {'x': [numpy array], 'y': [numpy array]} (on one client)
    returns x, y, which are both numpy array of length: batch_size
data is a dict := {'x': [numpy array], 'y': [numpy array]} (on one client)
    returns x, y, which are both numpy array of length: batch_size
data is a dict : = { x : [ numpy array ] y : [ numpy array ] } ( on one client ) returns x y which are both numpy array of length : batch_size
def batch_data(data, batch_size, seed):
    '''
    data is a dict := {'x': [numpy array], 'y': [numpy array]} (on one client)
    returns x, y, which are both numpy array of length: batch_size
    '''
    data_x = data['x']
    data_y = data['y']

    # randomly shuffle data
    np.random.seed(seed)
    rng_state = np.random.get_state()
    np.random.shuffle(data_x)
    np.random.set_state(rng_state)
    np.random.shuffle(data_y)

    # loop through mini-batches
    for i in range(0, len(data_x), batch_size):
        batched_x = data_x[i:i+batch_size]
        batched_y = data_y[i:i+batch_size]
        yield (batched_x, batched_y)
def batch_data ( data , batch_size , seed ) : data_x = data [ 'x' ] data_y = data [ 'y' ] # randomly shuffle data np . random . seed ( seed ) rng_state = np . random . get_state ( ) np . random . shuffle ( data_x ) np . random . set_state ( rng_state ) np . random . shuffle ( data_y ) # loop through mini-batches for i in range ( 0 , len ( data_x ) , batch_size ) : batched_x = data_x [ i : i + batch_size ] batched_y = data_y [ i : i + batch_size ] yield ( batched_x , batched_y )