Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

tensorflow 1.x spp implementation

def spatial_pyramid_pool(previous_conv, num_sample, previous_conv_size, out_pool_size):
  """
  previous_conv: a tensor vector of previous convolution layer
  num_sample: an int number of image in the batch
  previous_conv_size: an int vector [height, width] of the matrix features size of previous convolution layer
  out_pool_size: a int vector of expected output size of max pooling layer
  
  returns: a tensor vector with shape [1 x n] is the concentration of multi-level pooling
  """
  for i in range(len(out_pool_size)):
    h_strd = h_size = math.ceil(float(previous_conv_size[0]) / out_pool_size[i])
    w_strd = w_size = math.ceil(float(previous_conv_size[1]) / out_pool_size[i])
    pad_h = int(out_pool_size[i] * h_size - previous_conv_size[0])
    pad_w = int(out_pool_size[i] * w_size - previous_conv_size[1])
    new_previous_conv = tf.pad(previous_conv, tf.constant([[0, 0], [0, pad_h], [0, pad_w], [0, 0]]))
    max_pool = tf.nn.max_pool(new_previous_conv,
                   ksize=[1,h_size, h_size, 1],
                   strides=[1,h_strd, w_strd,1],
                   padding='SAME')
    if (i == 0):
      spp = tf.reshape(max_pool, [num_sample, -1])
    else:
      spp = tf.concat(axis=1, values=[spp, tf.reshape(max_pool, [num_sample, -1])])
  
  return spp
Comment

PREVIOUS NEXT
Code Example
Python :: python simplenamespace to json 
Python :: vscode show when variable is protected or private python 
Python :: function multiply(a b) 
Python :: Examples of correct code for this rule with global declaration: 
Python :: groupby and add aggregated column 
Python :: How to allow discord bot to respond to webhook. Python. Discord.py 
Python :: block-all-mixed-content csp bypass python 
Python :: how to access specific index of matrix in python 
Python :: ignore exception decorator 
Python :: Trying to set up flask with nginx and gunicorn 
Python :: Redirecting an old URL to a new one with Flask micro-framework 
Python :: jsfakjfkjadjfksajfa 
Python :: how to import grades into a text file in python 
Python :: flask login attemted_user cant see check_password_correction method 
Python :: converter json em form-data-encoded python 
Python :: dictionary, accepting similar words solution 
Python :: candelstick chart matplotlib 
Python :: ring Desktop, WebAssembly and Mobile Using QTreeView and QFileSystemModel 
Python :: update a variable in torch 
Python :: get most recurring element in a list python 
Python :: pandas to sql arabic 
Python :: colorgram.py 1.2.0 
Python :: ConversionofDatatypes-I 
Python :: matplotlib three dimensional plot 
Python :: RuntimeError: Please use tf.experimental.tensorrt.Converter in TF 2.0. site:stackoverflow.com 
Python :: turtle meaning 
Python :: alexa in python 
Python :: pandas exploring dataframe 
Python :: discord py replace characters from string 
Python :: python audio graph live stream 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =