Skip to content

Instantly share code, notes, and snippets.

@willtownes
Created September 21, 2020 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willtownes/42421f40a0c62fbcab7a18bd4d091a80 to your computer and use it in GitHub Desktop.
Save willtownes/42421f40a0c62fbcab7a18bd4d091a80 to your computer and use it in GitHub Desktop.
GPflow multioutput
from gpflow.conditionals import conditional
from gpflow.inducing_variables import SeparateIndependentInducingVariables
from gpflow.kernels import SeparateIndependent
#note: object 'm' is of type gpflow.models.svgp.SVGP
ind_conditional = conditional.dispatch(
object, SeparateIndependentInducingVariables, SeparateIndependent, object)
gmu, gvar = ind_conditional(
X,
m.inducing_variable,
m.kernel,
m.q_mu,
full_cov=False,
q_sqrt=m.q_sqrt,
full_output_cov=False,
white=False
)
# extract fitted parameters
Wfit = m.kernel.W.numpy()
fm,fv = m.predict_f(X)
fm = fm.numpy()
fm2 = gmu.numpy()@Wfit.T
np.max(np.abs(fm2-fm))
@willtownes
Copy link
Author

Variable 'X' is just the training data

@willtownes
Copy link
Author

for others stumbling on this in the future, the solution was to change white=True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment