I implemented a customized loss function for SVI according to https://github.com/uber/pyro/issues/958:
The loss function looks like:
def customized_loss(model, guide, *args, **kwargs):
guide_trace = poutine.trace(guide).get_trace(*args)
model_trace = poutine.trace(poutine.replay(model, trace=guide_trace)).get_trace(*args)
model_log_p = model_trace.log_prob_sum()
guide_log_p = guide_trace.log_prob_sum()
addtional_term = get_additional_term(...)
return -model_log_p + guide_log_p + additional_term
Basically, my loss function is:
My first question is: what's the relationship between
guide_lop_p and the KL divergence term in the loss function?
My second question is: Sometimes I observe
guide_log_p to be a positive value, which does not make sense because log likelihood should always be a negative value. Is my understanding wrong? Or, if my understanding is correct, how could I debug in this situation?
Thanks a lot!