Initial commit
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import numpy as np
|
||||
import time
|
||||
|
||||
rng = np.random.default_rng(int(time.monotonic()))
|
||||
|
||||
def uniform(shape: tuple, mu: float = 0.5, std: float = 1.0) -> np.ndarray:
|
||||
return std * (rng.uniform(size=shape) + mu - 0.5)
|
||||
|
||||
def gaussian(shape: tuple, mu: float = 0.5, std: float = 1.0) -> np.ndarray:
|
||||
return rng.normal(size=shape, loc=mu, scale=std)
|
||||
|
||||
def sample(src: np.ndarray) -> np.ndarray:
|
||||
return (src > uniform(src.shape)).astype(float)
|
||||
|
||||
def prob(src: np.ndarray) -> np.ndarray:
|
||||
return 1.0 / (1 + np.exp(-src))
|
||||
Reference in New Issue
Block a user