docstr: Test max pooling with a little bit more complex 'roi_proposals'.
  We have 4 'roi_proposals' and use a 'pool size'
  of 2x2 ('pooled_width': 2, 'pooled_height': 2), then we will get as
  result a 'roi_pool' of 2x2. with
docstr_tok: ["Test","max","pooling","with","a","little","bit","more","complex","'roi_proposals","'",".","We","have","4","'roi_proposals","'","and","use","a","'pool","size'","of","2x2","(","'pooled_width","'",":","2",",","'pooled_height","'",":","2",")",",","then","we","will","get","as","result","a","'roi_pool","'","of","2x2",".","with"]
code: def testMaxPoolingWithoutInterpolation(self):
      """
      Test max pooling with a little bit more complex 'roi_proposals'.
      We have 4 'roi_proposals' and use a 'pool size'
      of 2x2 ('pooled_width': 2, 'pooled_height': 2), then we will get as
      result a 'roi_pool' of 2x2. with
      """
      roi_proposals = np.array(
          [
              [3, 1, 6, 4],  # Across mat_A and mat_B (half-half)
              [1, 3, 4, 7],  # Across mat_A and mat_C (half-half)
              [5, 3, 9, 7],  # Inside mat_B and mat_D (half-half)
              [3, 6, 6, 9],  # Inside mat_C and mat_D (half-half)
          ]
      )
      a = self.multiplier_a
      b = self.multiplier_b
      c = self.multiplier_c
      d = self.multiplier_d
  
      results = self._run_roi_pooling(
          roi_proposals, self.pretrained, self.config
      )
  
      # Check that crops has the correct shape. This is (4, 4, 4, 1)
      # because we have 4 proposals, 'pool size' = 2x2 then the
      # tf.image.crop_and_resize function duplicates that size.
      self.assertEqual(results["crops"].shape, (4, 4, 4, 1))
  
      # Check that roi_pool has the correct shape. This is (4, 2, 2, 1)
      # because we have 4 proposals, 'pool size' = 2x2.
      self.assertEqual(results["roi_pool"].shape, (4, 2, 2, 1))
  
      results["roi_pool"] = np.squeeze(results["roi_pool"], axis=3)
      # Check that max polling returns a column of 'one' and
      # a column of 'two'.
      self.assertAllEqual(
          results["roi_pool"][0], np.array([[a, b], [a, b]])
      )
  
      # Check that max polling returns a row of 'one' and
      # a row of 'three'.
      self.assertAllEqual(
          results["roi_pool"][1], np.array([[a, a], [c, c]])
      )
  
      # Check that max polling returns a row of 'one' and
      # a row of 'three'.
      self.assertAllEqual(
          results["roi_pool"][2], np.array([[b, b], [d, d]])
      )
  
      # Check that max polling returns a column of 'three' and
      # a column of 'four'.
      self.assertAllEqual(
          results["roi_pool"][3], np.array([[c, d], [c, d]])
      )
  
file_path: luminoth/luminoth/models/fasterrcnn/roi_pool_test.py
imports: import numpy
  import tensorflow
  from easydict import EasyDict
  from luminoth.models.fasterrcnn.roi_pool import ROIPoolingLayer
label_desc: Use image node_id 4 for calling the ROIPoolingTest obj's underlying member method code with example usage: obj.testMaxPoolingWithoutInterpolation() without return types