def test_sample(self): sys.stdout.write('RectRectRBM -> Performing sample test ...') numx.random.seed(420) input_dim = 8 hidden_dim = 10 batchsize = 3 rbm = Model.RectRectRBM(input_dim, hidden_dim) data = numx.random.rand(batchsize, input_dim) h = rbm.probability_h_given_v(data) assert numx.all(h >= 0.0) assert numx.all(h.shape == (batchsize, hidden_dim)) h = rbm.sample_h(h) assert numx.all(h >= 0.0) assert numx.all(h <= rbm.max_act) assert numx.all(h.shape == (batchsize, hidden_dim)) v = rbm.probability_v_given_h(h) assert numx.all(v >= 0.0) assert numx.all(v.shape == (batchsize, input_dim)) v = rbm.sample_v(v) assert numx.all(v >= 0.0) assert numx.all(v <= rbm.max_act) assert numx.all(v.shape == (batchsize, input_dim)) sys.stdout.flush() print(' successfully passed!') sys.stdout.flush() pass
def test___init__(self): sys.stdout.write('RectRectRBM -> Performing init test ...') numx.random.seed(42) input_dim = 8 hidden_dim = 10 batchsize = 3 rbm = Model.RectRectRBM(input_dim, hidden_dim) assert numx.all(rbm.w.shape == (input_dim, hidden_dim)) assert numx.all(rbm.bv.shape == (1, input_dim)) assert numx.all(rbm.bh.shape == (1, hidden_dim)) assert numx.all(rbm.input_dim == input_dim) assert numx.all(rbm.output_dim == hidden_dim) print(' successfully passed!') sys.stdout.flush() pass