Skip to content

Commit

Permalink
Fixed adding multiple constraint terms to the log likelihood
Browse files Browse the repository at this point in the history
  • Loading branch information
josh0-jrg committed Jan 29, 2024
1 parent d50b217 commit c87b4b0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions flamedisx/likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,15 @@ def _log_likelihood(self,
0.)
if dsetname == self.dsetnames[0]:
if constraint_extra_args is None:
ll += self.log_constraint(**params_unstacked)
ll += tf.where( tf.equal(i_batch, tf.constant(0, dtype=fd.int_type())),
self.log_constraint(**params_unstacked),
0.)
else:
kwargs = {**params_unstacked, **constraint_extra_args}
ll += self.log_constraint(**kwargs)
ll += tf.where( tf.equal(i_batch, tf.constant(0, dtype=fd.int_type())),
self.log_constraint(**kwargs),
0.)


# Autodifferentiation. This is why we use tensorflow:
grad = tf.gradients(ll, grad_par_stack)[0]
Expand Down

0 comments on commit c87b4b0

Please sign in to comment.