Beispiel #1
0
def test_normal_onevox_sample():
    """ sample() method returns correct shape of data and is consistent with input mean/var """
    with tf.Session() as session:
        means = np.array([3.0], dtype=np.float32)
        variances = np.array([2.0], dtype=np.float32)

        post = NormalPosterior(means, variances)

        session.run(tf.global_variables_initializer())
        sample = session.run(post.sample(100))
        assert list(sample.shape) == [1, 1, 100]
        # Check for silly values
        assert np.all(sample < 100)
        assert np.all(sample > -100)
Beispiel #2
0
def test_normal_multivox_sample():
    """ test_normal_onevox_sample for more than one voxel """
    with tf.Session() as session:
        nvoxels_in = 34
        means = np.random.normal(5.0, 3.0, [nvoxels_in])
        variances = np.square(np.random.normal(2.5, 1.6, [nvoxels_in]))

        post = NormalPosterior(means, variances)

        session.run(tf.global_variables_initializer())
        sample = session.run(post.sample(100))
        assert sample.shape[0] == nvoxels_in
        assert sample.shape[1] == 1
        assert sample.shape[2] == 100
        # Check for silly values
        assert np.all(sample < 100)
        assert np.all(sample > -100)