예제 #1
0
 def setUp(self):
     self.n_samples = 10
     self.layer = SBN(
         n_X=16,
         n_Y=8,
     )
     self.layer.setup()
예제 #2
0
class TestSBN(RWSLayerTest, unittest.TestCase):
    def setUp(self):
        self.n_samples = 10
        self.layer = SBN(
                        n_X=16,
                        n_Y=8,
                    )
        self.layer.setup()
예제 #3
0
class TestSBN(RWSLayerTest, unittest.TestCase):
    def setUp(self):
        self.n_samples = 10
        self.layer = SBN(
            n_X=16,
            n_Y=8,
        )
        self.layer.setup()
예제 #4
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
예제 #5
0
 def setUp(self):
     self.n_samples = 10
     self.layer = SBN(
                     n_X=16,
                     n_Y=8,
                 )
     self.layer.setup()
예제 #6
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
예제 #7
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()
예제 #8
0
from learning.training import Trainer

from learning.models.rws import LayerStack
from learning.models.sbn import SBN, SBNTop
from learning.models.darn import DARN, DARNTop
from learning.models.nade import NADE, NADETop

n_vis = 28 * 28

dataset = CalTechSilhouettes(which_set='train')
valiset = CalTechSilhouettes(which_set='valid')
testset = CalTechSilhouettes(which_set='test')

p_layers = [
    SBN(
        n_X=n_vis,
        n_Y=500,
    ),
    SBN(
        n_X=500,
        n_Y=300,
    ),
    SBN(
        n_X=300,
        n_Y=100,
    ),
    SBN(
        n_X=100,
        n_Y=50,
    ),
    SBN(
        n_X=50,