(self, layer, I, O, argmax=None, beta=0.0)
Forward propagate pooling layer.

        Arguments:
            layer (PoolLayer): The pool layer object, different backends have
                               different pool layers.
            I (Tensor): Input tensor.
            O (Tensor): output tensor.
            argmax (Tensor): tensor to store location of the maximum
Forward propagate pooling layer.
Forward propagate pooling layer .
def fprop_pool(self, layer, I, O, argmax=None, beta=0.0):
        """
        Forward propagate pooling layer.

        Arguments:
            layer (PoolLayer): The pool layer object, different backends have
                               different pool layers.
            I (Tensor): Input tensor.
            O (Tensor): output tensor.
            argmax (Tensor): tensor to store location of the maximum
        """

        assert layer.sizeI == I.size
        assert layer.sizeO == O.size
        if layer.op == "max":
            assert layer.sizeO == argmax.size
        op = layer.op

        J, T, R, S = layer.JTRS
        C, D, H, W, N = layer.dimI
        K, M, P, Q, N = layer.dimO
        pad_c, pad_d, pad_h, pad_w = layer.padding
        str_c, str_d, str_h, str_w = layer.strides

        array_I = I._tensor.reshape(layer.dimI)
        array_O = O._tensor.reshape(layer.dimO)
        if op == "max":
            array_argmax = argmax._tensor.reshape(layer.dimO)

        for k in range(K):
            sliceC, _ = layer.kSlice[k]

            for m in range(M):
                sliceD, _ = layer.mSlice[m]

                for p in range(P):
                    sliceH, _ = layer.pSlice[p]

                    for q in range(Q):
                        sliceW, _ = layer.qSlice[q]

                        sliceI = array_I[sliceC, sliceD, sliceH, sliceW, :].reshape(-1, N)
                        if op == "max":
                            array_argmax[k, m, p, q, :] = np.argmax(sliceI, axis=0)
                            array_O[k, m, p, q, :] = array_O[k, m, p, q, :] * beta + \
                                np.max(sliceI, axis=0)
                        elif op == "avg":
                            array_O[k, m, p, q, :] = array_O[k, m, p, q, :] * beta + \
                                np.mean(sliceI, axis=0)
                        elif op == "l2":
                            array_O[k, m, p, q, :] = array_O[k, m, p, q, :] * beta + \
                                np.sqrt(np.sum(np.square(sliceI), axis=0))
def fprop_pool ( self , layer , I , O , argmax = None , beta = 0.0 ) : assert layer . sizeI == I . size assert layer . sizeO == O . size if layer . op == "max" : assert layer . sizeO == argmax . size op = layer . op J , T , R , S = layer . JTRS C , D , H , W , N = layer . dimI K , M , P , Q , N = layer . dimO pad_c , pad_d , pad_h , pad_w = layer . padding str_c , str_d , str_h , str_w = layer . strides array_I = I . _tensor . reshape ( layer . dimI ) array_O = O . _tensor . reshape ( layer . dimO ) if op == "max" : array_argmax = argmax . _tensor . reshape ( layer . dimO ) for k in range ( K ) : sliceC , _ = layer . kSlice [ k ] for m in range ( M ) : sliceD , _ = layer . mSlice [ m ] for p in range ( P ) : sliceH , _ = layer . pSlice [ p ] for q in range ( Q ) : sliceW , _ = layer . qSlice [ q ] sliceI = array_I [ sliceC , sliceD , sliceH , sliceW , : ] . reshape ( - 1 , N ) if op == "max" : array_argmax [ k , m , p , q , : ] = np . argmax ( sliceI , axis = 0 ) array_O [ k , m , p , q , : ] = array_O [ k , m , p , q , : ] * beta + np . max ( sliceI , axis = 0 ) elif op == "avg" : array_O [ k , m , p , q , : ] = array_O [ k , m , p , q , : ] * beta + np . mean ( sliceI , axis = 0 ) elif op == "l2" : array_O [ k , m , p , q , : ] = array_O [ k , m , p , q , : ] * beta + np . sqrt ( np . sum ( np . square ( sliceI ) , axis = 0 ) )