From 1b51861daf5c0fc46444461708f9aa2a2025e65d Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Thu, 18 Dec 2025 16:06:27 +0100 Subject: [PATCH] fixed contamination of function parameter --- src/rbm/cd_train.py | 4 ++-- src/rbm/entity.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/rbm/cd_train.py b/src/rbm/cd_train.py index eb27117..0cbf1bf 100644 --- a/src/rbm/cd_train.py +++ b/src/rbm/cd_train.py @@ -2,10 +2,10 @@ import numpy as np from collections.abc import Callable from params import RbmParams -from matrix import sample, gaussian +from matrix import prob, sample, gaussian def cd_jens(v_states: np.ndarray, params: RbmParams, v_to_ph: Callable, h_to_pv: Callable): - v_probs = v_states + v_probs = prob(v_states) h_states = v_to_ph(v_states) h_probs = h_states diff --git a/src/rbm/entity.py b/src/rbm/entity.py index 9ff2cea..50bc93a 100644 --- a/src/rbm/entity.py +++ b/src/rbm/entity.py @@ -76,18 +76,18 @@ class Entity: def gibbs_v_to_h(self, v: np.ndarray) -> np.ndarray: - h = None - for i in range(self.params.num_gibbs_samples): - h = self.v_to_ph(v) - v = self.h_to_pv(h) + h = self.v_to_ph(v) + for i in range(self.params.num_gibbs_samples-1): + h = self.h_to_pv(h) + h = self.v_to_ph(h) return h def gibbs_h_to_v(self, h: np.ndarray) -> np.ndarray: - v = None - for i in range(self.params.num_gibbs_samples): - v = self.h_to_pv(h) - h = self.v_to_ph(v) + v = self.h_to_pv(h) + for i in range(self.params.num_gibbs_samples-1): + v = self.v_to_ph(v) + v = self.h_to_pv(v) return v