def test_single_positive_sample(): nn_state = PositiveWaveFunction(10, 7, gpu=False) sample = nn_state.sample(k=10).squeeze() h_sample = nn_state.sample_h_given_v(sample) v_prob = nn_state.prob_v_given_h(h_sample) msg = "Single hidden sample should give a " assert v_prob.dim() == 1, msg
def test_sampling_with_overwrite(): nn_state = PositiveWaveFunction(10, gpu=False) old_state = torch.empty(100, 10).bernoulli_().to(dtype=torch.double) initial_state = old_state.clone() sample = nn_state.sample(k=10, initial_state=initial_state, overwrite=True) assert torch.equal(sample, initial_state), "initial_state did not get overwritten!" assert not torch.equal(sample, old_state), "Markov Chain did not get updated!"