Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bnn-1-layer
with pm.Model() as bnn:
x_data = pm.Data("x_data", x_input)
y_data = pm.Data("y_data", y_input)
#weights and bias prior
w_1 = pm.Normal("w_1", 0, sigma=1, shape=(layer_in, layer_nodes[0]))
b_1 = pm.Normal("b_1", 0, sigma=3, shape=1)
#w_2 = pm.Normal("w_2", 0, sigma=1, shape=(layer_nodes[0], layer_nodes[1]))
#b_2 = pm.Normal("b_2", 0, sigma=3, shape=1)
w_out = pm.Normal("w_out", 0, sigma=1, shape=(layer_nodes[1], ))
b_out = pm.Normal("b_out", 0, sigma=3, shape=1)
#activations and flow
act_1 = pm.Deterministic('act_1', pm.math.tanh(pm.math.dot(x_data, w_1) + b_1))
#act_2 = pm.Deterministic('act_2', pm.math.tanh(pm.math.dot(act_1, w_2) + b_2))
#act_out = pm.Deterministic('act_out', pm.math.dot(act_2, w_out) + b_out)
act_out = pm.Deterministic('act_out', pm.math.dot(act_1, w_out) + b_out)
sigma = pm.HalfNormal('sigma', sigma=0.1)
output = pm.Normal('output', act_out, sigma=1, observed=y_data, total_size=y_input.shape[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment