docstr: Test basic max pooling. 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.
docstr_tok: ["Test","basic","max","pooling",".","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","."]
code: def testBasic(self):
      """
      Test basic max pooling. 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.
      """
      roi_proposals = np.array(
          [
              [1, 1, 4, 4],  # Inside mat_A
              [6, 1, 9, 4],  # Inside mat_B
              [1, 6, 4, 9],  # Inside mat_C
              [6, 6, 9, 9],  # Inside mat_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 only 'multiplier_a'
      self.assertAllEqual(
          results["roi_pool"][0], np.ones((2, 2)) * self.multiplier_a
      )
  
      # Check that max polling returns only 'multiplier_b'
      self.assertAllEqual(
          results["roi_pool"][1], np.ones((2, 2)) * self.multiplier_b
      )
  
      # Check that max polling returns only 'multiplier_c'
      self.assertAllEqual(
          results["roi_pool"][2], np.ones((2, 2)) * self.multiplier_c
      )
  
      # Check that max polling returns only 'multiplier_d'
      self.assertAllEqual(
          results["roi_pool"][3], np.ones((2, 2)) * self.multiplier_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 3 for calling the ROIPoolingTest obj's underlying member method code with example usage: obj.testBasic() without return types