Skip to content

Add loss history to Approximate to give pm.fit() access to it. #2219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pymc3/variational/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ def fit(self, n=10000, score=None, callbacks=None, progressbar=True,
self._iterate_with_loss(n, step_func, progress, callbacks)
else:
self._iterate_without_loss(n, step_func, progress, callbacks)

# hack to allow pm.fit() access to loss hist
self.approx.hist = self.hist

return self.approx

def _iterate_without_loss(self, _, step_func, progress, callbacks):
Expand Down Expand Up @@ -579,7 +583,7 @@ class ASVGD(Inference):

\Delta x_i &= \hat{\phi}^{*}(x_i) \\
\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)] \\
\Delta_{\theta} &= \frac{1}{n}\sum^{n}_{i=1}\Delta x_i\frac{\partial x_i}{\partial \theta}
\Delta_{\theta} &= \frac{1}{n}\sum^{n}_{i=1}\Delta x_i\frac{\partial x_i}{\partial \theta}

Parameters
----------
Expand Down