Beispiel #1
0
class TestSBNTop(RWSTopLayerTest, unittest.TestCase):
    def setUp(self):
        self.n_samples = 10
        self.layer = SBNTop(
                        n_X=8
                    )
        self.layer.setup()
Beispiel #2
0
def get_toy_model():
    from learning.models.rws import LayerStack
    from learning.models.sbn import SBN, SBNTop

    p_layers = [SBN(n_X=25, n_Y=10), SBNTop(n_X=10, )]
    q_layers = [SBN(
        n_X=10,
        n_Y=25,
    )]
    model = LayerStack(
        p_layers=p_layers,
        q_layers=q_layers,
    )
    return model
Beispiel #3
0
def test_FromModel():
    D = 5
    n_vis = D**2
    n_hid = 2 * D

    # Ground truth params
    W_bars = np.zeros([n_hid, D, D])
    for d in xrange(D):
        W_bars[d, d, :] = 4.
        W_bars[D + d, :, d] = 4.
    W_bars = W_bars.reshape((n_hid, n_vis))
    P_a = -np.log(D / 2 - 1) * np.ones(n_hid)
    P_b = -2 * np.ones(n_vis)

    # Instantiate model...
    p_layers = [SBN(
        n_X=n_vis,
        n_Y=n_hid,
    ), SBNTop(n_X=n_hid)]
    q_layers = [SBN(
        n_X=n_hid,
        n_Y=n_vis,
    )]
    p_layers[0].set_model_param('W', W_bars)
    p_layers[0].set_model_param('b', P_b)
    p_layers[1].set_model_param('a', P_a)

    model = LayerStack(p_layers=p_layers, q_layers=q_layers)

    # ...and generate data
    n_datapoints = 1000
    data = FromModel(model=model, n_datapoints=n_datapoints)

    assert data.X.shape == (n_datapoints, n_vis)

    yield check_dtype, data
    yield check_range, data
Beispiel #4
0
 def setUp(self):
     p_layers = [
         SBN(
             n_X=self.n_vis,
             n_Y=self.n_hid,
         ),
         SBN(
             n_X=self.n_hid,
             n_Y=self.n_hid,
         ),
         SBNTop(n_X=self.n_hid)
     ]
     q_layers = [
         SBN(
             n_Y=self.n_vis,
             n_X=self.n_hid,
         ),
         SBN(
             n_Y=self.n_hid,
             n_X=self.n_hid,
         )
     ]
     self.stack = LayerStack(p_layers=p_layers, q_layers=q_layers)
     self.stack.setup()
Beispiel #5
0
 def setUp(self):
     self.n_samples = 10
     self.layer = SBNTop(
                     n_X=8
                 )
     self.layer.setup()
Beispiel #6
0
        n_X=500,
        n_Y=300,
    ),
    SBN(
        n_X=300,
        n_Y=100,
    ),
    SBN(
        n_X=100,
        n_Y=50,
    ),
    SBN(
        n_X=50,
        n_Y=10,
    ),
    SBNTop(n_X=10, )
]

q_layers = [
    SBN(
        n_Y=n_vis,
        n_X=500,
    ),
    SBN(
        n_Y=500,
        n_X=300,
    ),
    SBN(
        n_Y=300,
        n_X=100,
    ),
Beispiel #7
0
 def setUp(self):
     self.n_samples = 10
     self.layer = SBNTop(n_X=8)
     self.layer.setup()
Beispiel #8
0
class TestSBNTop(RWSTopLayerTest, unittest.TestCase):
    def setUp(self):
        self.n_samples = 10
        self.layer = SBNTop(n_X=8)
        self.layer.setup()