def test_ScaleParameter(): """Tests probflow.parameters.ScaleParameter""" # Create the parameter param = ScaleParameter() # All samples should be > 0 assert np.all(param.posterior_sample(n=1000) > 0) # 1D ScaleParameter param = ScaleParameter(shape=5) samples = param.posterior_sample(n=10) assert samples.ndim == 2 assert samples.shape[0] == 10 assert samples.shape[1] == 5 assert np.all(samples > 0) # 2D ScaleParameter param = ScaleParameter(shape=[5, 4]) samples = param.posterior_sample(n=10) assert samples.ndim == 3 assert samples.shape[0] == 10 assert samples.shape[1] == 5 assert samples.shape[2] == 4 assert np.all(samples > 0)
def __init__(self, d: List[int], heteroscedastic: bool = False, **kwargs): self.heteroscedastic = heteroscedastic if heteroscedastic: d[-1] = 2 * d[-1] self.network = DenseNetwork(d, **kwargs) else: self.network = DenseNetwork(d, **kwargs) self.std = ScaleParameter([1, 1], name='std')
def __init__(self, d: int, heteroscedastic: bool = False): self.heteroscedastic = heteroscedastic if heteroscedastic: self.weights = Parameter([d, 2], name='weights') self.bias = Parameter([1, 1], name='bias') else: self.weights = Parameter([d, 1], name='weights') self.bias = Parameter([1, 1], name='bias') self.std = ScaleParameter([1, 1], name='std')
def __init__(self, d: int, d_o: int = 1, heteroscedastic: bool = False): self.heteroscedastic = heteroscedastic if heteroscedastic: self.d_o = d_o self.weights = Parameter([d, d_o * 2], name="weights") self.bias = Parameter([1, d_o * 2], name="bias") else: self.weights = Parameter([d, d_o], name="weights") self.bias = Parameter([1, d_o], name="bias") self.std = ScaleParameter([1, d_o], name="std")
def __init__(self): self.weight = Parameter(name="Weight") self.bias = Parameter(name="Bias") self.std = ScaleParameter(name="Std")
def __init__(self, d_in, d_out): self.weight = Parameter([d_in, d_out], name="Weight") self.bias = Parameter([1, d_out], name="Bias") self.std = ScaleParameter([1, d_out], name="Std")
def __init__(self): self.module = MyModule() self.std = ScaleParameter([1, 1], name="Std", prior=Gamma(1.0, 1.0))
def __init__(self): self.mean = Parameter([1], name="Mean") self.std = ScaleParameter([1], name="Std")
def __init__(self, cols): self.cols = cols self.weight = Parameter([len(cols), 1], name="Weight") self.bias = Parameter([1, 1], name="Bias") self.std = ScaleParameter([1, 1], name="Std")
def __init__(self, d: int): self.weights = Parameter([d, 1], name='weights') self.bias = Parameter(name='bias') self.std = ScaleParameter(name='std')
def __init__(self, d: List[int]): self.network = DenseNetwork(d) self.std = ScaleParameter(name='std')