Skip to content

Commit c546ad2

Browse files
twieckiferrine
authored andcommitted
Add loss history to Approximate to give pm.fit() access to it. (#2219)
1 parent 67de240 commit c546ad2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pymc3/variational/inference.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ def fit(self, n=10000, score=None, callbacks=None, progressbar=True,
123123
self._iterate_with_loss(n, step_func, progress, callbacks)
124124
else:
125125
self._iterate_without_loss(n, step_func, progress, callbacks)
126+
127+
# hack to allow pm.fit() access to loss hist
128+
self.approx.hist = self.hist
129+
126130
return self.approx
127131

128132
def _iterate_without_loss(self, _, step_func, progress, callbacks):
@@ -579,7 +583,7 @@ class ASVGD(Inference):
579583
580584
\Delta x_i &= \hat{\phi}^{*}(x_i) \\
581585
\hat{\phi}^{*}(x) &= \frac{1}{n}\sum^{n}_{j=1}[k(x_j,x) \nabla_{x_j} logp(x_j)+ \nabla_{x_j} k(x_j,x)] \\
582-
\Delta_{\theta} &= \frac{1}{n}\sum^{n}_{i=1}\Delta x_i\frac{\partial x_i}{\partial \theta}
586+
\Delta_{\theta} &= \frac{1}{n}\sum^{n}_{i=1}\Delta x_i\frac{\partial x_i}{\partial \theta}
583587
584588
Parameters
585589
----------

0 commit comments

Comments
 (0)