def batch_iter(data, batch_size, num_epochs, shuffle=True):
    '\n    Generates a batch iterator for a dataset.\n    '
    data = np.array(data)
    data_size = len(data)
    num_batches_per_epoch = (int((len(data) / batch_size)) + 1)
    for epoch in range(num_epochs):
        if shuffle:
            shuffle_indices = np.random.permutation(np.arange(data_size))
            shuffled_data = data[shuffle_indices]
        else:
            shuffled_data = data
        for batch_num in range(num_batches_per_epoch):
            start_index = (batch_num * batch_size)
            end_index = min(((batch_num + 1) * batch_size), data_size)
            (yield shuffled_data[start_index:end_index])
Generates a batch iterator for a dataset.
def batch_iter(data, batch_size, num_epochs, shuffle=True):
    '\n    \n    '
    data = np.array(data)
    data_size = len(data)
    num_batches_per_epoch = (int((len(data) / batch_size)) + 1)
    for epoch in range(num_epochs):
        if shuffle:
            shuffle_indices = np.random.permutation(np.arange(data_size))
            shuffled_data = data[shuffle_indices]
        else:
            shuffled_data = data
        for batch_num in range(num_batches_per_epoch):
            start_index = (batch_num * batch_size)
            end_index = min(((batch_num + 1) * batch_size), data_size)
            (yield shuffled_data[start_index:end_index])