(input_tensor, pool_op=tf.nn.avg_pool)
return output
Applies avg pool to produce 1x1 output.

  NOTE: This function is funcitonally equivalenet to reduce_mean, but it has
  baked in average pool which has better support across hardware.

  Args:
    input_tensor: input tensor
    pool_op: pooling op (avg pool is default)
  Returns:
    a tensor batch_size x 1 x 1 x depth.
Applies avg pool to produce 1x1 output.
Applies avg pool to produce 1x1 output .
def global_pool(input_tensor, pool_op=tf.nn.avg_pool):
  """Applies avg pool to produce 1x1 output.

  NOTE: This function is funcitonally equivalenet to reduce_mean, but it has
  baked in average pool which has better support across hardware.

  Args:
    input_tensor: input tensor
    pool_op: pooling op (avg pool is default)
  Returns:
    a tensor batch_size x 1 x 1 x depth.
  """
  shape = input_tensor.get_shape().as_list()
  if shape[1] is None or shape[2] is None:
    kernel_size = tf.convert_to_tensor(
        [1, tf.shape(input_tensor)[1],
         tf.shape(input_tensor)[2], 1])
  else:
    kernel_size = [1, shape[1], shape[2], 1]
  output = pool_op(
      input_tensor, ksize=kernel_size, strides=[1, 1, 1, 1], padding='VALID')
  # Recover output shape, for unknown shape.
  output.set_shape([None, 1, 1, None])
  return output
def global_pool ( input_tensor , pool_op = tf . nn . avg_pool ) : shape = input_tensor . get_shape ( ) . as_list ( ) if shape [ 1 ] is None or shape [ 2 ] is None : kernel_size = tf . convert_to_tensor ( [ 1 , tf . shape ( input_tensor ) [ 1 ] , tf . shape ( input_tensor ) [ 2 ] , 1 ] ) else : kernel_size = [ 1 , shape [ 1 ] , shape [ 2 ] , 1 ] output = pool_op ( input_tensor , ksize = kernel_size , strides = [ 1 , 1 , 1 , 1 ] , padding = 'VALID' ) # Recover output shape, for unknown shape. output . set_shape ( [ None , 1 , 1 , None ] ) return output