Пример #1
0
 def testMaxPooling2DPaddingSame(self):
   height, width = 7, 9
   images = random_ops.random_uniform((5, height, width, 4), seed=1)
   layer = pooling_layers.MaxPooling2D(
       images.get_shape()[1:3], strides=2, padding='same')
   output = layer.apply(images)
   self.assertListEqual(output.get_shape().as_list(), [5, 4, 5, 4])
Пример #2
0
 def testCreateMaxPooling2DChannelsFirst(self):
   height, width = 7, 9
   images = random_ops.random_uniform((5, 2, height, width))
   layer = pooling_layers.MaxPooling2D([2, 2],
                                       strides=1,
                                       data_format='channels_first')
   output = layer.apply(images)
   self.assertListEqual(output.get_shape().as_list(), [5, 2, 6, 8])
Пример #3
0
  def testCreatePooling2DWithStrides(self):
    height, width = 6, 8
    # Test strides tuple
    images = random_ops.random_uniform((5, height, width, 3), seed=1)
    layer = pooling_layers.MaxPooling2D([2, 2], strides=(2, 2), padding='same')
    output = layer.apply(images)
    self.assertListEqual(output.get_shape().as_list(),
                         [5, height / 2, width / 2, 3])

    # Test strides integer
    layer = pooling_layers.MaxPooling2D([2, 2], strides=2, padding='same')
    output = layer.apply(images)
    self.assertListEqual(output.get_shape().as_list(),
                         [5, height / 2, width / 2, 3])

    # Test unequal strides
    layer = pooling_layers.MaxPooling2D([2, 2], strides=(2, 1), padding='same')
    output = layer.apply(images)
    self.assertListEqual(output.get_shape().as_list(),
                         [5, height / 2, width, 3])
Пример #4
0
 def testCreateMaxPooling2D(self):
   height, width = 7, 9
   images = random_ops.random_uniform((5, height, width, 4))
   layer = pooling_layers.MaxPooling2D([2, 2], strides=2)
   output = layer.apply(images)
   self.assertListEqual(output.get_shape().as_list(), [5, 3, 4, 4])