Hi,
Let me start by saying I am very new to GP modeling.
I have adapted the codes from the Multi-output Gaussian Processes Notebook to my own system. The ICM model in the notebook worked on my data for 1 batch of the data set. However, I need help in modifying the model when I want to train it on 6 batches of data. I’m guessing the modification has to do with the shapes of the parameters.
Each batch has an output of y_species(t), for 11 time points and for 6 species.
Here is what my input array looks like for all 6 Batches:
# First column
time = np.tile([1, 15, 30, 45, 60, 120, 180, 300, 420, 720, 1080], 36)
# Second, third, and fourth columns. Features related to each batch.
X1 = np.repeat([0.427, 0.427, 0.639, 0.249, 0.860, 0.427], 66)
X2 = np.repeat([0.389, 0.389, 0.389, 0.227, 0.782, 0.389], 66)
X3 = np.repeat([0.467, 0.542, 0.467, 0.273, 0.935, 0.427], 66)
# Fifth column
speciesIDX = np.tile(np.repeat([0, 1, 2, 3, 4, 5], 11), 6)
# Combine into a single array
input_array = np.column_stack((time, X1, X2, X3, speciesIDX))
The following model works when it is trained on the Batch 1 data (first 66 elements):
def get_icm(input_dim, kernel, W=None, kappa=None, B=None, active_dims=None):
"""
This function generates an ICM kernel from an input kernel and a Coregion kernel.
"""
coreg = pm.gp.cov.Coregion(input_dim=input_dim, W=W, kappa=kappa, B=B, active_dims=active_dims)
icm_cov = kernel * coreg # Use Hadamard Product for separate inputs
return icm_cov
X = input_array[:66,:]
Y = output[:66]
with pm.Model() as model:
# Priors
ell = pm.Gamma("ell", alpha=5, beta=2)
eta = pm.Gamma("eta", alpha=0.5, beta=0.1)
kernel = eta**2 * pm.gp.cov.ExpQuad(input_dim=5, ls=ell, active_dims=[0])
sigma = pm.HalfNormal("sigma", sigma=0.06)
# Get the ICM kernel
W = pm.Normal("W", mu=0, sigma=1, shape=(6, 2), initval=np.random.randn(6, 2))
kappa = pm.Gamma("kappa", alpha=3.0, beta=2.0, shape=6)
B = pm.Deterministic("B", pt.dot(W, W.T) + pt.diag(kappa))
cov_icm = get_icm(input_dim=5, kernel=kernel, B=B, active_dims=[4])
# Define a Multi-output GP
mogp = pm.gp.Marginal(cov_func=cov_icm)
y_ = mogp.marginal_likelihood("f", X, Y, sigma=sigma)
How do I modify this model when I want to train it on 6 batches of data?
Many thanks,