Пример #1
0
def test_stochasatic_pool_samples():
    """
    check if the order of frequency of samples from stochastic max pool
    are same as the order of input values.
    """

    ds = 3
    stride = 3
    rng = numpy.random.RandomState(220)
    data = rng.uniform(0, 10, size=(1, ds, ds, 1)).astype('float32')

    x = theano.tensor.tensor4()
    s_max = stochastic_max_pool_c01b(x, (ds, ds), (stride, stride))
    f = theano.function([x], s_max, mode=mode_with_gpu)

    samples = []
    for i in xrange(300):
        samples.append(numpy.asarray(f(data))[0, 0, 0, 0])

    counts = Counter(samples)
    data = data.reshape(ds * ds)
    data.sort()
    data = data[::-1]
    for i in range(len(data) - 1):
        assert counts[data[i]] >= counts[data[i + 1]]
Пример #2
0
def test_stochasatic_pool_samples():
    """
    check if the order of frequency of samples from stochastic max pool
    are same as the order of input values.
    """

    ds = 3
    stride = 3
    rng = numpy.random.RandomState(220)
    data = rng.uniform(0, 10, size=(1, ds, ds, 1)).astype('float32')

    x = theano.tensor.tensor4()
    s_max = stochastic_max_pool_c01b(x, (ds, ds), (stride, stride))
    f = theano.function([x], s_max, mode=mode_with_gpu)

    samples = []
    for i in xrange(300):
        samples.append(numpy.asarray(f(data))[0, 0, 0, 0])

    counts = Counter(samples)
    data = data.reshape(ds*ds)
    data.sort()
    data = data[::-1]
    for i in range(len(data) - 1):
        assert counts[data[i]] >= counts[data[i+1]]