def _collect_and_generate_bottlenecks(self, image_gen):
    'Consumes a generator and converts all images to bottlenecks.\n\n    Args:\n      image_gen: A Keras data generator for images to process\n\n    Returns:\n      Two NumPy arrays: (bottlenecks, labels).\n    '
    collected_bottlenecks = np.zeros(((image_gen.samples,) + BOTTLENECK_SHAPE), dtype=np.float32)
    collected_labels = np.zeros((image_gen.samples, NUM_CLASSES), dtype=np.float32)
    next_idx = 0
    for (bottlenecks, truth) in self._generate_bottlenecks(make_finite(image_gen)):
        batch_size = bottlenecks.shape[0]
        collected_bottlenecks[next_idx:(next_idx + batch_size)] = bottlenecks
        collected_labels[next_idx:(next_idx + batch_size)] = truth
        next_idx += batch_size
    return (collected_bottlenecks, collected_labels)
Consumes a generator and converts all images to bottlenecks.

Args:
  image_gen: A Keras data generator for images to process

Returns:
  Two NumPy arrays: (bottlenecks, labels).
def _collect_and_generate_bottlenecks(self, image_gen):
    'Consumes a generator and converts all images to bottlenecks.\n\n    Args:\n      image_gen: A Keras data generator for images to process\n\n    Returns:\n      Two NumPy arrays: (bottlenecks, labels).\n    '
    collected_bottlenecks = np.zeros(((image_gen.samples,) + BOTTLENECK_SHAPE), dtype=np.float32)
    collected_labels = np.zeros((image_gen.samples, NUM_CLASSES), dtype=np.float32)
    next_idx = 0
    for (bottlenecks, truth) in self._generate_bottlenecks(make_finite(image_gen)):
        batch_size = bottlenecks.shape[0]
        collected_bottlenecks[next_idx:(next_idx + batch_size)] = bottlenecks
        collected_labels[next_idx:(next_idx + batch_size)] = truth
        next_idx += batch_size
    return (collected_bottlenecks, collected_labels)