class_docstr: Wrapper that adds a prediction method to a feature extraction link.
  
  The :meth:`predict` takes three steps to make a prediction.
  
  1. Preprocess input images
  2. Forward the preprocessed images to the network
  3. Average features in the case when more than one crops are extracted.
  
  Example:
  
      >>> from chainercv.links import VGG16
      >>> from chainercv.links import FeaturePredictor
      >>> base_model = VGG16()
      >>> model = FeaturePredictor(base_model, 224, 256)
      >>> prob = model.predict([img])
      # Predicting multiple features
      >>> model.extractor.pick = ['conv5_3', 'fc7']
      >>> conv5_3, fc7 = model.predict([img])
  
  When :obj:`self.crop == 'center'`, :meth:`predict` extracts features from
  the center crop of the input images.
  When :obj:`self.crop == '10'`, :meth:`predict` extracts features from
  patches that are ten-cropped from the input images.
  
  When extracting more than one crops from an image, the output of
  :meth:`predict` returns the average of the features computed from the
  crops.
  
  Args:
      extractor: A feature extraction link. This is a callable chain
          that takes a batch of images and returns a variable or a
          tuple of variables.
      crop_size (int or tuple): The height and the width of an image after
          cropping in preprocessing.
          If this is an integer, the image is cropped to
          :math:`(crop\_size, crop\_size)`.
      scale_size (int or tuple): If :obj:`scale_size` is :obj:`None`,
          neither scaling nor resizing is conducted during preprocessing.
          This is the default behavior.
          If this is an integer, an image is resized so that the length of
          the shorter edge is equal to :obj:`scale_size`. If this is a tuple
          :obj:`(height, width)`, the image is resized to
          :math:`(height, width)`.
      crop ({'center', '10'}): Determines the style of cropping.
      mean (numpy.ndarray): A mean value. If this is :obj:`None`,
          :obj:`extractor.mean` is used as the mean value.
class_docstr_tok: ["Wrapper","that","adds","a","prediction","method","to","a","feature","extraction","link",".","The",":","meth",":","`","predict","`","takes","three","steps","to","make","a","prediction",".","1",".","Preprocess","input","images","2",".","Forward","the","preprocessed","images","to","the","network","3",".","Average","features","in","the","case","when","more","than","one","crops","are","extracted",".","Example",":",">",">",">","from","chainercv.links","import","VGG16",">",">",">","from","chainercv.links","import","FeaturePredictor",">",">",">","base_model","=","VGG16","(",")",">",">",">","model","=","FeaturePredictor","(","base_model",",","224",",","256",")",">",">",">","prob","=","model.predict","(","[","img","]",")","#","Predicting","multiple","features",">",">",">","model.extractor.pick","=","[","'conv5_3","'",",","'fc7","'","]",">",">",">","conv5_3",",","fc7","=","model.predict","(","[","img","]",")","When",":","obj",":","`","self.crop","==","'center","'","`",",",":","meth",":","`","predict","`","extracts","features","from","the","center","crop","of","the","input","images",".","When",":","obj",":","`","self.crop","==","'10","'","`",",",":","meth",":","`","predict","`","extracts","features","from","patches","that","are","ten-cropped","from","the","input","images",".","When","extracting","more","than","one","crops","from","an","image",",","the","output","of",":","meth",":","`","predict","`","returns","the","average","of","the","features","computed","from","the","crops",".","Args",":","extractor",":","A","feature","extraction","link",".","This","is","a","callable","chain","that","takes","a","batch","of","images","and","returns","a","variable","or","a","tuple","of","variables",".","crop_size","(","int","or","tuple",")",":","The","height","and","the","width","of","an","image","after","cropping","in","preprocessing",".","If","this","is","an","integer",",","the","image","is","cropped","to",":","math",":","`","(","crop\\_size",",","crop\\_size",")","`",".","scale_size","(","int","or","tuple",")",":","If",":","obj",":","`","scale_size","`","is",":","obj",":","`","None","`",",","neither","scaling","nor","resizing","is","conducted","during","preprocessing",".","This","is","the","default","behavior",".","If","this","is","an","integer",",","an","image","is","resized","so","that","the","length","of","the","shorter","edge","is","equal","to",":","obj",":","`","scale_size","`",".","If","this","is","a","tuple",":","obj",":","`","(","height",",","width",")","`",",","the","image","is","resized","to",":","math",":","`","(","height",",","width",")","`",".","crop","(","{","'center","'",",","'10","'","}",")",":","Determines","the","style","of","cropping",".","mean","(","numpy.ndarray",")",":","A","mean","value",".","If","this","is",":","obj",":","`","None","`",",",":","obj",":","`","extractor.mean","`","is","used","as","the","mean","value","."]
code: def _average_crops(self, y, n_crop):
      if y.ndim == 4:
          warnings.warn(
              "Four dimensional features are averaged. "
              "If these are batch of 2D spatial features, "
              "their spatial information would be lost."
          )
  
      xp = chainer.backends.cuda.get_array_module(y)
      y = y.reshape((-1, n_crop) + y.shape[1:])
      y = xp.mean(y, axis=1)
      return y
  
file_path: chainercv/chainercv/links/model/feature_predictor.py
imports: import numpy
  import warnings
  import chainer
  from chainer.backends import cuda
  from chainercv.transforms import center_crop
  from chainercv.transforms import resize
  from chainercv.transforms import scale
  from chainercv.transforms import ten_crop
label_desc: Use image node_id 3 for calling the FeaturePredictor obj's underlying member method code with example usage: obj._average_crops(y, n_crop) and returns: y