def setUp(self): self.n_samples = 10 self.layer = SBN( n_X=16, n_Y=8, ) self.layer.setup()
class TestSBN(RWSLayerTest, unittest.TestCase): def setUp(self): self.n_samples = 10 self.layer = SBN( n_X=16, n_Y=8, ) self.layer.setup()
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
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
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()
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,