refactored

This commit is contained in:
2025-12-18 07:56:08 +01:00
parent c06fc7f485
commit eb975da018
4 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ import numpy as np
from collections.abc import Callable
from params import RbmParams
from helper import sample, gaussian
from matrix import sample, gaussian
def cd_jens(v_states: np.ndarray, params: RbmParams, v_to_ph: Callable, h_to_pv: Callable):
v_probs = v_states
+1 -1
View File
@@ -2,7 +2,7 @@ import numpy as np
from collections.abc import Callable
from params import RbmParams
from state import RbmState
from helper import sample, prob, uniform, rms_error_accu
from matrix import sample, prob, rms_error_accu
from status import Status
from cd_train import cd_jens
+3 -3
View File
@@ -1,5 +1,5 @@
import numpy as np
from helper import uniform
from matrix import uniform
class RbmState:
@@ -33,10 +33,10 @@ class RbmState:
return obj
def v_to_h(self, visible: np.ndarray) -> np.ndarray:
return np.vecmat(visible, self.w_hv) + self.b_h
return np.dot(visible, self.w_hv) + self.b_h
def h_to_v(self, hidden: np.ndarray) -> np.ndarray:
return np.vecmat(hidden, np.transpose(self.w_hv)) + self.b_v
return np.dot(hidden, np.transpose(self.w_hv)) + self.b_v
def to_file(self, filename: str):
np.savez(filename, whv=self.w_hv, bv=self.b_v, bh=self.b_h)