def feed_numpy(batch_size, *arrays):
  """Given a set of numpy arrays, produce slices of batch_size.

  Note: You can use itertools.cycle to have this repeat forever.

  Args:
    batch_size: The batch_size for each array.
    *arrays: A list of arrays.
  Yields:
    A list of slices from the arrays of length batch_size except the last one
    which will contain the rest.
  Raises:
    ValueError: If arrays aren't all the same length or no arrays are provided.
  """
  if not arrays:
    raise ValueError('Arrays cannot be empty.')
  size = len(arrays[0])
  for a in arrays:
    if size != len(a):
      raise ValueError('All arrays must be the same size.')
  count = int(size / batch_size)

  for i in xrange(count):
    start = i * batch_size
    end = start + batch_size
    yield [x[start:end] for x in arrays]
  if count * batch_size < size:
    yield [x[end:] for x in arrays]
Given a set of numpy arrays, produce slices of batch_size.

  Note: You can use itertools.cycle to have this repeat forever.

  Args:
    batch_size: The batch_size for each array.
    *arrays: A list of arrays.
  Yields:
    A list of slices from the arrays of length batch_size except the last one
    which will contain the rest.
  Raises:
    ValueError: If arrays aren't all the same length or no arrays are provided.