cd_binary_binary: added gibbs sampling
This commit is contained in:
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user