Esempio n. 1
0
 def test_3D(self):
     inp = Nplike(
         A([[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
            [[2, 3, 4], [5, 6, 7], [8, 9, 1]]]))
     resmax = a_pool(inp, inp.shape, (2, 2), mode="max")
     resavg = a_pool(inp, inp.shape, (2, 2), mode="avg")
     array_almost_equal(
         resmax.eval(),
         A([[[5.0, 6.0], [8.0, 9.0]], [[6.0, 7.0], [9.0, 9.0]]]))
     array_almost_equal(
         resavg.eval(),
         A([[[3.0, 4.0], [6.0, 7.0]], [[4.0, 5.0], [7.0, 5.75]]]))
Esempio n. 2
0
 def test_simple2(self):
     inp = Nplike(A([[[1, 2], [3, 4]]]))
     resmax = a_pool(inp, inp.shape, (2, 2), mode="max")
     resavg = a_pool(inp, inp.shape, (2, 2), mode="avg")
     array_almost_equal(resmax.eval(), A([[[4.0]]]))
     array_almost_equal(resavg.eval(), A([[[2.5]]]))
Esempio n. 3
0
 def test_2D2(self):
     inp = Nplike(A([[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]))
     resmax = a_pool(inp, inp.shape, (3, 3), mode="max")
     resavg = a_pool(inp, inp.shape, (3, 3), mode="avg")
     array_almost_equal(resmax.eval(), A([[[9.0]]]))
     array_almost_equal(resavg.eval(), A([[[5.0]]]))
Esempio n. 4
0
 def test_simple(self):
     inp = nplike([[[1, 2], [3, 4]]])
     resmax = a_pool(inp, inp.shape, (1, 1), mode="max")
     resavg = a_pool(inp, inp.shape, (1, 1), mode="avg")
     array_almost_equal(resmax.eval(), inp.eval())
     array_almost_equal(resavg.eval(), inp.eval())