train: fixed gaussian sampling

This commit is contained in:
2026-01-03 19:30:47 +01:00
parent e6c959d890
commit 6546c37657
+5 -4
View File
@@ -97,7 +97,7 @@ def cd_gaussian_binary(entity: Entity, data_pos: Mat):
# Positive phase
if params.do_batch_sample:
h_probs_pos = entity.h_given_v(sample_gaussian(data_pos))
h_probs_pos = entity.h_given_v(data_pos + sample_gaussian(data_pos))
else:
h_probs_pos = entity.h_given_v(data_pos)
@@ -126,12 +126,13 @@ def cd_gaussian_gaussian(entity: Entity, data_pos: Mat):
# Positive phase
if params.do_batch_sample:
h_probs_pos = entity.h_given_v(sample_gaussian(data_pos))
h_probs_pos = entity.h_given_v(data_pos + sample_gaussian(data_pos))
else:
h_probs_pos = entity.h_given_v(data_pos)
# Sample hidden states
h_probs_pos += sample_gaussian(h_probs_pos)
if not params.do_rao_blackwell:
# Sample hidden states
h_probs_pos += sample_gaussian(h_probs_pos)
# Update weights (positive phase)
dw = np.dot(np.transpose(data_pos), h_probs_pos)