diff --git a/src/rbm/train.py b/src/rbm/train.py index 52c3b7c..f998965 100644 --- a/src/rbm/train.py +++ b/src/rbm/train.py @@ -101,9 +101,9 @@ def cd_gaussian_binary(entity: Entity, data_pos: Mat): dbh = np.sum(h_probs_pos, 0) dbv = np.sum(data_pos-entity.state.b_v, 0) - # Negative phase - data_neg = entity.v_given_h(h_probs_pos) - h_probs_neg = prob(entity.h_given_v(data_neg + sample_gaussian(data_neg))) + # Negative phase — sample binary hidden states to get a sharper fantasy particle + data_neg = entity.v_given_h(sample(h_probs_pos)) + h_probs_neg = prob(entity.h_given_v(data_neg)) # Update weights (negative phase) dw -= np.dot(np.transpose(data_neg), h_probs_neg)