Skip to content

Commit

Permalink
Change/rewrite at.nnet functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jdehning committed Mar 1, 2023
1 parent 7649efd commit 9bffeba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions covid19_inference/model/utility.py
Expand Up @@ -143,7 +143,7 @@ def tt_lognormal(x, mu, sigma):
"""
Calculates a lognormal pdf for integer spaced x input.
"""
x = at.nnet.relu(x - 1e-12) + 1e-12 # clip values at 1e-12
x = at.maximum(x, 1e-12) # clip values at 1e-12
distr = 1 / x * at.exp(-((at.log(x) - mu) ** 2) / (2 * sigma**2))

# normalize, add a small offset in case the sum is zero
Expand All @@ -159,7 +159,7 @@ def tt_gamma(x, mu=None, sigma=None, alpha=None, beta=None):
if alpha is None and beta is None:
alpha = mu**2 / (sigma**2 + 1e-8)
beta = mu / (sigma**2 + 1e-8)
x = at.nnet.relu(x - 1e-12) + 1e-12 # clip values at 1e-12
x = at.maximum(x, 1e-12) # clip values at 1e-12
distr = beta**alpha * x ** (alpha - 1) * at.exp(-beta * x)

# normalize, add a small offset in case the sum is zero
Expand Down
2 changes: 1 addition & 1 deletion covid19_inference/model/week_modulation.py
Expand Up @@ -338,7 +338,7 @@ def by_weekday_modulation(cases, model=None):
)
r_week = r_base + delta_r

r_transformed_week = at.nnet.sigm.sigmoid(r_week)
r_transformed_week = at.math.sigmoid(r_week)
pm.Deterministic("fraction_delayed_by_weekday", r_week)

t = np.arange(model.sim_shape[0]) + model.sim_begin.weekday() # Monday @ zero
Expand Down

0 comments on commit 9bffeba

Please sign in to comment.