def test_forward(self): layer = tl.SumPool(pool_size=(2, 2), strides=(2, 2)) x = np.array([[ [[1, 2, 3], [4, 5, 6], [10, 20, 30], [40, 50, 60]], [[4, 2, 3], [7, 1, 2], [40, 20, 30], [70, 10, 20]], ]]) y = layer(x) self.assertEqual(tl.to_list(y), [[[[16, 10, 14], [160, 100, 140]]]])
def test_padding_same(self): layer = tl.SumPool(pool_size=(3, ), strides=(3, ), padding='SAME') # One padding position needed; add at end. x = np.array([[[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]]) y = layer(x) self.assertEqual(tl.to_list(y), [[[3, 24], [7, 11]]]) # Two padding positions needed; add one at end and one at start. x = np.array([[[0, 9], [1, 8], [2, 7], [3, 6]]]) y = layer(x) self.assertEqual(tl.to_list(y), [[[1, 17], [5, 13]]])
def test_forward_shape(self): layer = tl.SumPool(pool_size=(2, 2), strides=(1, 2)) x = np.ones((11, 6, 4, 17)) y = layer(x) self.assertEqual(y.shape, (11, 5, 2, 17))