Example #1
0
def ref_sum_pooling_3d(x, kernel, stride, ignore_border, pad):
    y = []
    for xx in x.reshape((-1,) + x.shape[-4:]):
        if xx.ndim == 3:
            xx = xx[np.newaxis]
        y += [refs.pooling_3d(xx, 'sum', kernel, stride,
                              pad, ignore_border)[np.newaxis]]
    y = np.vstack(y)
    if x.ndim == 3:
        y = np.squeeze(y, 1)
    return y.reshape(x.shape[:-4] + y.shape[1:])
Example #2
0
def ref_average_pooling_3d(x, kernel, stride, ignore_border, pad,
                           including_pad):
    print(x)
    y = []
    for xx in x.reshape((-1, ) + x.shape[-4:]):
        if xx.ndim == 3:
            xx = xx[np.newaxis]
        y += [
            refs.pooling_3d(xx, 'average', kernel, stride, pad, ignore_border,
                            including_pad)[np.newaxis]
        ]
    y = np.vstack(y)
    if x.ndim == 3:
        y = np.squeeze(y, 1)
    print(y.reshape(x.shape[:-4] + y.shape[1:]))
    return y.reshape(x.shape[:-4] + y.shape[1:])