mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-30 14:35:15 +02:00
[bgplvm] technical new stuff
This commit is contained in:
parent
4ca4916cc0
commit
fca2440943
5 changed files with 15 additions and 5 deletions
|
|
@ -161,6 +161,16 @@ class NormalPosterior(VariationalPosterior):
|
|||
from ...plotting.matplot_dep import variational_plots
|
||||
return variational_plots.plot(self, *args, **kwargs)
|
||||
|
||||
def KL(self, other):
|
||||
"""Compute the KL divergence to another NormalPosterior Object. This only holds, if the two NormalPosterior objects have the same shape, as we do computational tricks for the multivariate normal KL divergence.
|
||||
"""
|
||||
return .5*(
|
||||
np.sum(self.variance/other.variance)
|
||||
+ ((other.mean-self.mean)**2/other.variance).sum()
|
||||
- self.num_data * self.input_dim
|
||||
+ np.sum(np.log(other.variance)) - np.sum(np.log(self.variance))
|
||||
)
|
||||
|
||||
class SpikeAndSlabPosterior(VariationalPosterior):
|
||||
'''
|
||||
The SpikeAndSlab distribution for variational approximations.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue