Esempio n. 1
0
def test_gaussian_vis_layer_make_state():
    """
    Verifies that GaussianVisLayer.make_state creates
    a shared variable whose value passes check_gaussian_samples

    In this case the layer lives in a VectorSpace

    """
    n = 5
    rows = None
    cols = None
    channels = None
    num_samples = 1000
    tol = .042 # tolerated variance
    beta = 1/tol # precision parameter

    layer = GaussianVisLayer(nvis = n, init_beta=beta)

    rng = np.random.RandomState([2012,11,1])

    mean = rng.uniform(1e-6, 1. - 1e-6, (n,))

    z= mean

    layer.set_biases(z.astype(config.floatX))

    init_state = layer.make_state(num_examples=num_samples,
            numpy_rng=rng)

    value = init_state.get_value()

    check_gaussian_samples(value, num_samples, n, rows, cols, channels, mean, tol)
Esempio n. 2
0
def test_gaussian_vis_layer_make_state():
    """
    Verifies that GaussianVisLayer.make_state creates
    a shared variable whose value passes check_gaussian_samples

    In this case the layer lives in a VectorSpace

    """
    n = 5
    rows = None
    cols = None
    channels = None
    num_samples = 1000
    tol = .042  # tolerated variance
    beta = 1 / tol  # precision parameter

    layer = GaussianVisLayer(nvis=n, init_beta=beta)

    rng = np.random.RandomState([2012, 11, 1])

    mean = rng.uniform(1e-6, 1. - 1e-6, (n, ))

    z = mean

    layer.set_biases(z.astype(config.floatX))

    init_state = layer.make_state(num_examples=num_samples, numpy_rng=rng)

    value = init_state.get_value()

    check_gaussian_samples(value, num_samples, n, rows, cols, channels, mean,
                           tol)
Esempio n. 3
0
def test_gaussian_vis_layer_make_state_conv():
    """
    Verifies that GaussianVisLayer.make_state creates
    a shared variable whose value passes check_gaussian_samples

    In this case the layer lives in a Conv2DSpace

    """
    n = None
    rows = 3
    cols = 3
    channels = 3
    num_samples = 1000
    tol = .042  # tolerated variance
    beta = 1 / tol  # precision parameter
    # axes for batch, rows, cols, channels, can be given in any order
    axes = ['b', 0, 1, 'c']
    random.shuffle(axes)
    axes = tuple(axes)
    print 'axes:', axes

    layer = GaussianVisLayer(rows=rows,
                             cols=cols,
                             channels=channels,
                             init_beta=beta,
                             axes=axes)

    # rng = np.random.RandomState([2012,11,1])
    rng = np.random.RandomState()
    mean = rng.uniform(1e-6, 1. - 1e-6, (rows, cols, channels))

    #z = inverse_sigmoid_numpy(mean)
    z = mean

    layer.set_biases(z.astype(config.floatX))

    init_state = layer.make_state(num_examples=num_samples, numpy_rng=rng)

    value = init_state.get_value()

    check_gaussian_samples(value, num_samples, n, rows, cols, channels, mean,
                           tol)
Esempio n. 4
0
def test_gaussian_vis_layer_make_state_conv():
    """
    Verifies that GaussianVisLayer.make_state creates
    a shared variable whose value passes check_gaussian_samples

    In this case the layer lives in a Conv2DSpace

    """
    n = None
    rows = 3
    cols = 3
    channels = 3
    num_samples = 1000
    tol = .042  # tolerated variance
    beta = 1/tol  # precision parameter
    # axes for batch, rows, cols, channels, can be given in any order
    axes = ['b', 0, 1, 'c']
    random.shuffle(axes)
    axes = tuple(axes)
    print 'axes:', axes

    layer = GaussianVisLayer(rows=rows, cols=cols, channels=channels, init_beta=beta, axes=axes)

    # rng = np.random.RandomState([2012,11,1])
    rng = np.random.RandomState()
    mean = rng.uniform(1e-6, 1. - 1e-6, (rows, cols, channels))

    #z = inverse_sigmoid_numpy(mean)
    z= mean

    layer.set_biases(z.astype(config.floatX))

    init_state = layer.make_state(num_examples=num_samples,
            numpy_rng=rng)

    value = init_state.get_value()

    check_gaussian_samples(value, num_samples, n, rows, cols, channels, mean, tol)