@float32_floatX
def test_top_donw_correctness():
    """
    Test the forward pass Op against theano graph implementation
    """

    rng = np.random.RandomState([2012,7,19])
    batch_size_list = [1]
    channels = 16
    rows_list = [2, 24]
    pool_rows_list = [2, 3]

    # TODO theano graph version fails with pool shape 1,1,
    # try it with python version

    for batch_size in batch_size_list:
        for rows, pool_rows in zip(rows_list, pool_rows_list):
            cols = rows
            pool_cols = pool_rows

            zv = rng.randn(channels, rows, cols, batch_size).astype(config.floatX)
            tv = rng.randn(channels, rows / pool_rows, cols / pool_cols, batch_size).astype(config.floatX)

            z = T.tensor4()
            t = T.tensor4()

            # gpu op
            p, h = prob_max_pool_c01b(z, (pool_rows, pool_cols), top_down = t)
            func = function([z, t], [p, h], mode = mode_with_gpu)

            p_op, h_op = func(zv, tv)

            # theano graph
            p, h = max_pool_c01b(z, (pool_rows, pool_cols), top_down = t)
            func = function([z, t], [p, h], mode = mode_without_gpu)

            p_th, h_th = func(zv, tv)

            assert np.allclose(p_op, p_th)
            assert np.allclose(h_op, h_th)
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/sandbox/cuda_convnet/tests/test_probabilistic_max_pooling.py/test_top_donw_correctness/original