refactored

This commit is contained in:
2025-12-16 14:59:07 +01:00
parent b6e94e75ac
commit 944b96448c
3 changed files with 11 additions and 11 deletions
+3 -3
View File
@@ -20,7 +20,7 @@ class RbmLayer:
def train_batch(self, v_states: np.ndarray, cd_func: Callable):
for epochs in range(self.params.num_epochs):
# Contrastive divergence learning: calculate gradients
cd_func(v_states, dwhv, dbh, dbv);
dwhv, dbh, dbv = cd_func(v_states)
@@ -36,9 +36,9 @@ if __name__ == "__main__":
v0 = uniform((1,2))
h0 = uniform((1,3))
h1 = l1.v_to_h(v0)
h1 = l1.state.v_to_h(v0)
print(h1.shape)
v1 = l1.h_to_v(h1)
v1 = l1.state.h_to_v(h1)
s_v1 = sample(v1)
p_h = prob(s_v1)