def test_forward(self): arr = np.random.rand(4, 4, 3) s = PoolingLayerSettings(in_shape=arr.shape, filter_size=2, stride=2) l = _PoolingLayer(s) res = l.forward(arr) print(arr[:, :, 0]) print(arr[:, :, 1]) print(arr[:, :, 2]) print('-----------') print(res[:, :, 0]) print(res[:, :, 1]) print(res[:, :, 2])
def test_backward(self): arr = np.random.rand(4, 4, 3) s = PoolingLayerSettings(in_shape=arr.shape, filter_size=2, stride=2) l = _PoolingLayer(s) l.next_layer = object() res_forw = l.forward(arr) res_back = l.backward(np.ones(s.out_shape)) print(arr[:, :, 0]) print(arr[:, :, 1]) print(arr[:, :, 2]) print('-----------') print(res_forw[:, :, 0]) print(res_forw[:, :, 1]) print(res_forw[:, :, 2]) print('-----------') print(res_back[:, :, 0]) print(res_back[:, :, 1]) print(res_back[:, :, 2])