cd_binary_binary: added gibbs sampling

This commit is contained in:
2026-01-01 20:02:22 +01:00
parent e67207504b
commit 8b97350564
3 changed files with 7 additions and 6 deletions
-1
View File
@@ -102,7 +102,6 @@ class Entity:
state = self.state.v_to_h(v)
return state
def v_given_h(self, h: Mat) -> Mat:
state = self.state.h_to_v(h)
return state
+4 -2
View File
@@ -100,8 +100,10 @@ def cd_binary_binary(entity: Entity, data_pos: Mat, params: TrainingParams):
data_neg = prob(entity.v_given_h(h_probs_pos))
h_probs_neg = prob(entity.h_given_v(data_neg))
# Gibbs sampling with training params
# ToDo
# Gibbs sampling
for _ in range(params.num_gibbs_samples-1):
data_neg = prob(entity.v_given_h(h_probs_neg))
h_probs_neg = prob(entity.h_given_v(data_neg))
# Update weights (negative phase)
dw -= np.dot(np.transpose(data_neg), h_probs_neg)