Skip to content

Commit

Permalink
fix handling of priors
Browse files Browse the repository at this point in the history
  • Loading branch information
t-vi committed Nov 6, 2017
1 parent 13ff9a4 commit 20209b8
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 117 deletions.
2 changes: 1 addition & 1 deletion candlegp/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def objective(self):
pos_objective = self.compute_log_likelihood()
for param in self.parameters():
if isinstance(param, parameter.ParamWithPrior):
pos_objective += param.get_prior()
pos_objective = pos_objective + param.get_prior()
return -pos_objective

def forward(self):
Expand Down
4 changes: 2 additions & 2 deletions candlegp/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def get_prior(self):
if self.prior is None:
return 0.0

log_jacobian = self.log_jacobian().sum() #(unconstrained_tensor)
logp_var = self.prior.logp(self.get()).sum()
log_jacobian = self.log_jacobian() #(unconstrained_tensor)
logp_var = self.prior.logp(self.get())
return log_jacobian+logp_var

class PositiveParam(ParamWithPrior): # log(1+exp(r))
Expand Down
180 changes: 66 additions & 114 deletions notebooks/gp_regression.ipynb

Large diffs are not rendered by default.

0 comments on commit 20209b8

Please sign in to comment.