Skip to content

Commit 9a894ce

Browse files
committed
inline _prepare_start_sigma and use expm1
1 parent 1bd4fda commit 9a894ce

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

pymc/variational/approximations.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,19 @@ def create_shared_params(self, start=None, start_sigma=None):
7979
# by `self.ordering`. In the cases I looked into these turn out to be the same, but there may be edge cases or
8080
# future code changes that break this assumption.
8181
start = self._prepare_start(start)
82-
rho = self._prepare_start_sigma(start_sigma)
83-
return {
84-
"mu": aesara.shared(pm.floatX(start), "mu"),
85-
"rho": aesara.shared(pm.floatX(rho), "rho"),
86-
}
82+
rho1 = np.zeros((self.ddim,))
8783

88-
def _prepare_start_sigma(self, start_sigma):
89-
rho = np.zeros((self.ddim,))
9084
if start_sigma is not None:
9185
for name, slice_, *_ in self.ordering.values():
9286
sigma = start_sigma.get(name)
9387
if sigma is not None:
94-
rho[slice_] = np.log(np.exp(np.abs(sigma)) - 1.0)
95-
return rho
88+
rho1[slice_] = np.log(np.expm1(np.abs(sigma)))
89+
rho = rho1
90+
91+
return {
92+
"mu": aesara.shared(pm.floatX(start), "mu"),
93+
"rho": aesara.shared(pm.floatX(rho), "rho"),
94+
}
9695

9796
@node_property
9897
def symbolic_random(self):

0 commit comments

Comments
 (0)