parameters: (inputs, kernel_size, stride, pad=0, padding='VALID',
             mode='MAX', data_format='NCHW', global_pooling=False, **kwargs)
return_statement: return output
docstring: 2D Pooling, MAX or AVG.
  
      The spatial output dimension of pooling can be computed as follows:
  
      |pooling_output_dim|
  
      Set ``padding`` to  **VALID** will use the value of ``pad``.
  
      If use ``global_pooling``, the stride and pad will be set to ``1`` and ``0`` automatically.
  
      Parameters
      ----------
      inputs : Tensor
          The input tensor.
      kernel_size : int or list
          The kernel size(s) of pooling.
      stride : int or list
          The stride(s) of of pooling,
      pad : int or list
          The zero padding size(s) of pooling. Default is ``0``.
      padding : str
          The padding algorithm. ``VALID`` or ``SAME``.
      mode : str
          The mode, ``MAX`` or ``AVG``.
      data_format : str
          The data format, ``NCHW`` or ``NHWC``.
      global_pooling : boolean
          Whether to use global pooling.
  
      Returns
      -------
      Tensor
          The output tensor.
docstring_summary: 2D Pooling, MAX or AVG.
docstring_tokens: 2D Pooling MAX or AVG .
function: def Pool2d(inputs, kernel_size, stride, pad=0, padding='VALID',
             mode='MAX', data_format='NCHW', global_pooling=False, **kwargs):
      """2D Pooling, MAX or AVG.
  
      The spatial output dimension of pooling can be computed as follows:
  
      |pooling_output_dim|
  
      Set ``padding`` to  **VALID** will use the value of ``pad``.
  
      If use ``global_pooling``, the stride and pad will be set to ``1`` and ``0`` automatically.
  
      Parameters
      ----------
      inputs : Tensor
          The input tensor.
      kernel_size : int or list
          The kernel size(s) of pooling.
      stride : int or list
          The stride(s) of of pooling,
      pad : int or list
          The zero padding size(s) of pooling. Default is ``0``.
      padding : str
          The padding algorithm. ``VALID`` or ``SAME``.
      mode : str
          The mode, ``MAX`` or ``AVG``.
      data_format : str
          The data format, ``NCHW`` or ``NHWC``.
      global_pooling : boolean
          Whether to use global pooling.
  
      Returns
      -------
      Tensor
          The output tensor.
  
      """
      CheckInputs(inputs, 1)
      arguments = ParseArguments(locals())
  
      if mode not in ('MAX', 'AVG'):
          raise ValueError('Unsupported lrn mode: {}'.format(mode))
      if padding not in ('VALID', 'SAME'):
          raise ValueError('Unsupported padding algorithm: {}'.format(padding))
      if data_format not in ('NCHW', 'NHWC'):
          raise ValueError('Unsupported data format: {}'.format(data_format))
  
      if not isinstance(arguments['kernel_size'], list):
          arguments['kernel_size'] = [arguments['kernel_size']]
      if not isinstance(arguments['stride'], list):
          arguments['stride'] = [arguments['stride']]
      if not isinstance(arguments['pad'], list):
          arguments['pad'] = [arguments['pad']]
  
      output = Tensor.CreateOperator(nout=1, op_type='Pooling2d', **arguments)
  
      if inputs.shape is not None:
          output.shape = inputs.shape[:]
          spatial_axis = 2 if data_format == 'NCHW' else 1
          for i in xrange(2):
              k = arguments['kernel_size'][i] if i < len(arguments['kernel_size']) \
                                              else arguments['kernel_size'][-1]
              s = arguments['stride'][i]      if i < len(arguments['stride']) \
                                              else arguments['stride'][-1]
              p = arguments['pad'][i]         if i < len(arguments['pad']) \
                                              else arguments['pad'][-1]
              if not global_pooling:
                  if padding != 'SAME':
                      input_size = output.shape[i + spatial_axis]
                      output_size = int(math.ceil((output.shape[i + spatial_axis] + 2 * p - k) / s) + 1)
                      if ((output_size - 1) * s >= input_size + p):
                          output_size = output_size - 1
                      output.shape[i + spatial_axis] = output_size
                  else:
                      output.shape[i + spatial_axis] = \
                          int((output.shape[i + spatial_axis] + s - 1) / s)
              else:
                  output.shape[i + spatial_axis] = 1
  
      return output
function_tokens: def Pool2d ( inputs , kernel_size , stride , pad = 0 , padding = 'VALID' , mode = 'MAX' , data_format = 'NCHW' , global_pooling = False , * * kwargs ) : CheckInputs ( inputs , 1 ) arguments = ParseArguments ( locals ( ) ) if mode not in ( 'MAX' , 'AVG' ) : raise ValueError ( 'Unsupported lrn mode: {}' . format ( mode ) ) if padding not in ( 'VALID' , 'SAME' ) : raise ValueError ( 'Unsupported padding algorithm: {}' . format ( padding ) ) if data_format not in ( 'NCHW' , 'NHWC' ) : raise ValueError ( 'Unsupported data format: {}' . format ( data_format ) ) if not isinstance ( arguments [ 'kernel_size' ] , list ) : arguments [ 'kernel_size' ] = [ arguments [ 'kernel_size' ] ] if not isinstance ( arguments [ 'stride' ] , list ) : arguments [ 'stride' ] = [ arguments [ 'stride' ] ] if not isinstance ( arguments [ 'pad' ] , list ) : arguments [ 'pad' ] = [ arguments [ 'pad' ] ] output = Tensor . CreateOperator ( nout = 1 , op_type = 'Pooling2d' , * * arguments ) if inputs . shape is not None : output . shape = inputs . shape [ : ] spatial_axis = 2 if data_format == 'NCHW' else 1 for i in xrange ( 2 ) : k = arguments [ 'kernel_size' ] [ i ] if i < len ( arguments [ 'kernel_size' ] ) else arguments [ 'kernel_size' ] [ - 1 ] s = arguments [ 'stride' ] [ i ] if i < len ( arguments [ 'stride' ] ) else arguments [ 'stride' ] [ - 1 ] p = arguments [ 'pad' ] [ i ] if i < len ( arguments [ 'pad' ] ) else arguments [ 'pad' ] [ - 1 ] if not global_pooling : if padding != 'SAME' : input_size = output . shape [ i + spatial_axis ] output_size = int ( math . ceil ( ( output . shape [ i + spatial_axis ] + 2 * p - k ) / s ) + 1 ) if ( ( output_size - 1 ) * s >= input_size + p ) : output_size = output_size - 1 output . shape [ i + spatial_axis ] = output_size else : output . shape [ i + spatial_axis ] = int ( ( output . shape [ i + spatial_axis ] + s - 1 ) / s ) else : output . shape [ i + spatial_axis ] = 1 return output