[cd_gaussian_binary] - fix negative phase: remove spurious noise, sample hidden states

In cd_gaussian_binary, two CD formulation bugs:
1. Gaussian noise was incorrectly added to data_neg before computing h_probs_neg
2. Negative visible reconstruction used h_probs_pos (soft probabilities) instead
   of sampled binary hidden states, biasing the fantasy particle toward the mean

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 14:36:18 +02:00
co-authored by Claude Sonnet 4.6
parent 3c85705d85
commit 07e430f109
+3 -3
View File
@@ -101,9 +101,9 @@ def cd_gaussian_binary(entity: Entity, data_pos: Mat):
dbh = np.sum(h_probs_pos, 0) dbh = np.sum(h_probs_pos, 0)
dbv = np.sum(data_pos-entity.state.b_v, 0) dbv = np.sum(data_pos-entity.state.b_v, 0)
# Negative phase # Negative phase — sample binary hidden states to get a sharper fantasy particle
data_neg = entity.v_given_h(h_probs_pos) data_neg = entity.v_given_h(sample(h_probs_pos))
h_probs_neg = prob(entity.h_given_v(data_neg + sample_gaussian(data_neg))) h_probs_neg = prob(entity.h_given_v(data_neg))
# Update weights (negative phase) # Update weights (negative phase)
dw -= np.dot(np.transpose(data_neg), h_probs_neg) dw -= np.dot(np.transpose(data_neg), h_probs_neg)