- fixed v_to_ph parameter consideration
- matrix: use different random implementations
This commit is contained in:
+1
-1
@@ -62,7 +62,7 @@ class Entity:
|
|||||||
|
|
||||||
def v_to_ph(self, v: np.ndarray) -> np.ndarray:
|
def v_to_ph(self, v: np.ndarray) -> np.ndarray:
|
||||||
state = self.state.v_to_h(v)
|
state = self.state.v_to_h(v)
|
||||||
if self.params.do_gaussian_visible:
|
if self.params.do_gaussian_hidden:
|
||||||
return state
|
return state
|
||||||
|
|
||||||
return prob(state)
|
return prob(state)
|
||||||
|
|||||||
+4
-4
@@ -1,13 +1,13 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import time
|
import time
|
||||||
|
|
||||||
rng = np.random.default_rng(int(time.monotonic()))
|
np.random.seed(int(time.monotonic()))
|
||||||
|
|
||||||
def uniform(shape: tuple, mu: float = 0.5, std: float = 1.0) -> np.ndarray:
|
def uniform(shape: tuple, mu: float = 0.5, std: float = 1.0) -> np.ndarray:
|
||||||
return std * (rng.uniform(size=shape) + mu - 0.5)
|
return std * (np.random.rand(shape[0], shape[1]) + mu - 0.5)
|
||||||
|
|
||||||
def gaussian(shape: tuple, mu: float = 0.5, std: float = 1.0) -> np.ndarray:
|
def gaussian(shape: tuple, mu: float = 0.0, std: float = 1.0) -> np.ndarray:
|
||||||
return rng.normal(size=shape, loc=mu, scale=std)
|
return std * (np.random.randn(shape[0], shape[1]) + mu)
|
||||||
|
|
||||||
def sample(src: np.ndarray) -> np.ndarray:
|
def sample(src: np.ndarray) -> np.ndarray:
|
||||||
return (src > uniform(src.shape)).astype(float)
|
return (src > uniform(src.shape)).astype(float)
|
||||||
|
|||||||
Reference in New Issue
Block a user