def forward(key, x): dim_in = x.shape[-1] w_key, b_key = random.split(key) w = ppl.random_variable(bd.Sample(bd.Normal(0., 1.), sample_shape=(dim_out, dim_in)), name=f'{name}_w')(w_key) b = ppl.random_variable(bd.Sample(bd.Normal(0., 1.), sample_shape=(dim_out, )), name=f'{name}_b')(b_key) return np.dot(w, x) + b
def _sample(key, s): return ppl.random_variable( bd.Sample(bd.Normal(0., 1.), sample_shape=s.shape))(key).astype(s.dtype)
def _sample(key, s): return ppl.random_variable( bd.Sample( bd.Normal(0., 1.), # pytype: disable=module-attr sample_shape=s.shape))(key).astype(s.dtype)