fixed cd_binary_binary
This commit is contained in:
+7
-9
@@ -85,22 +85,20 @@ def cd_jens(entity: Entity, v_states: Mat, params: TrainingParams):
|
||||
|
||||
def cd_binary_binary(entity: Entity, data_pos: Mat, params: TrainingParams):
|
||||
# Positive phase
|
||||
h_probs_pos = entity.h_given_v(data_pos)
|
||||
h_probs_pos = prob(entity.h_given_v(data_pos))
|
||||
|
||||
# Sample hidden states
|
||||
if not params.do_rao_blackwell:
|
||||
h_probs_pos = sample(h_probs_pos)
|
||||
|
||||
# Update weights (positive phase)
|
||||
dw = np.dot(np.transpose(data_pos), h_probs_pos)
|
||||
dbh = np.sum(h_probs_pos, 0)
|
||||
dbv = np.sum(data_pos, 0)
|
||||
|
||||
# Sample hidden states
|
||||
if params.do_rao_blackwell:
|
||||
h_states_pos = h_probs_pos
|
||||
else:
|
||||
h_states_pos = sample(h_probs_pos)
|
||||
|
||||
# Negative phase
|
||||
data_neg = entity.v_given_h(h_states_pos)
|
||||
h_probs_neg = entity.h_given_v(data_neg)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user