parameters: (
      sess, image_lists, how_many, category, image_dir, input_jpeg_tensor,
      distorted_image, resized_input_tensor, bottleneck_tensor)
return_statement: return bottlenecks, ground_truths
docstring: Retrieves bottleneck values for training images, after distortions.
  
    If we're training with distortions like crops, scales, or flips, we have to
    recalculate the full model for every image, and so we can't use cached
    bottleneck values. Instead we find random images for the requested category,
    run them through the distortion graph, and then the full graph to get the
    bottleneck results for each.
  
    Args:
      sess: Current TensorFlow Session.
      image_lists: Dictionary of training images for each label.
      how_many: The integer number of bottleneck values to return.
      category: Name string of which set of images to fetch - training, testing,
      or validation.
      image_dir: Root folder string of the subfolders containing the training
      images.
      input_jpeg_tensor: The input layer we feed the image data to.
      distorted_image: The output node of the distortion graph.
      resized_input_tensor: The input node of the recognition graph.
      bottleneck_tensor: The bottleneck output layer of the CNN graph.
  
    Returns:
      List of bottleneck arrays and their corresponding ground truths.
docstring_summary: Retrieves bottleneck values for training images, after distortions.
docstring_tokens: Retrieves bottleneck values for training images after distortions .
function: def get_random_distorted_bottlenecks(
      sess, image_lists, how_many, category, image_dir, input_jpeg_tensor,
      distorted_image, resized_input_tensor, bottleneck_tensor):
    """Retrieves bottleneck values for training images, after distortions.
  
    If we're training with distortions like crops, scales, or flips, we have to
    recalculate the full model for every image, and so we can't use cached
    bottleneck values. Instead we find random images for the requested category,
    run them through the distortion graph, and then the full graph to get the
    bottleneck results for each.
  
    Args:
      sess: Current TensorFlow Session.
      image_lists: Dictionary of training images for each label.
      how_many: The integer number of bottleneck values to return.
      category: Name string of which set of images to fetch - training, testing,
      or validation.
      image_dir: Root folder string of the subfolders containing the training
      images.
      input_jpeg_tensor: The input layer we feed the image data to.
      distorted_image: The output node of the distortion graph.
      resized_input_tensor: The input node of the recognition graph.
      bottleneck_tensor: The bottleneck output layer of the CNN graph.
  
    Returns:
      List of bottleneck arrays and their corresponding ground truths.
    """
    class_count = len(image_lists.keys())
    bottlenecks = []
    ground_truths = []
    for unused_i in range(how_many):
      label_index = random.randrange(class_count)
      label_name = list(image_lists.keys())[label_index]
      image_index = random.randrange(65536)
      image_path = get_image_path(image_lists, label_name, image_index, image_dir,
                                  category)
      if not gfile.Exists(image_path):
        tf.logging.fatal('File does not exist %s', image_path)
      jpeg_data = gfile.FastGFile(image_path, 'rb').read()
      # Note that we materialize the distorted_image_data as a numpy array before
      # sending running inference on the image. This involves 2 memory copies and
      # might be optimized in other implementations.
      distorted_image_data = sess.run(distorted_image,
                                      {input_jpeg_tensor: jpeg_data})
      bottleneck = run_bottleneck_on_image(sess, distorted_image_data,
                                           resized_input_tensor,
                                           bottleneck_tensor)
      ground_truth = np.zeros(class_count, dtype=np.float32)
      ground_truth[label_index] = 1.0
      bottlenecks.append(bottleneck)
      ground_truths.append(ground_truth)
    return bottlenecks, ground_truths
function_tokens: def get_random_distorted_bottlenecks ( sess , image_lists , how_many , category , image_dir , input_jpeg_tensor , distorted_image , resized_input_tensor , bottleneck_tensor ) : class_count = len ( image_lists . keys ( ) ) bottlenecks = [ ] ground_truths = [ ] for unused_i in range ( how_many ) : label_index = random . randrange ( class_count ) label_name = list ( image_lists . keys ( ) ) [ label_index ] image_index = random . randrange ( 65536 ) image_path = get_image_path ( image_lists , label_name , image_index , image_dir , category ) if not gfile . Exists ( image_path ) : tf . logging . fatal ( 'File does not exist %s' , image_path ) jpeg_data = gfile . FastGFile ( image_path , 'rb' ) . read ( ) # Note that we materialize the distorted_image_data as a numpy array before # sending running inference on the image. This involves 2 memory copies and # might be optimized in other implementations. distorted_image_data = sess . run ( distorted_image , { input_jpeg_tensor : jpeg_data } ) bottleneck = run_bottleneck_on_image ( sess , distorted_image_data , resized_input_tensor , bottleneck_tensor ) ground_truth = np . zeros ( class_count , dtype = np . float32 ) ground_truth [ label_index ] = 1.0 bottlenecks . append ( bottleneck ) ground_truths . append ( ground_truth ) return bottlenecks , ground_truths