So, I have encountered a weird bug when attempting to run a simple Gaussian Process model, and I am quite confused as to what is happening. My setup is Numpy: 1.16.0, Theano: 1.0.4, Pymc3: 3.6, and this problem persists across both my Ubuntu work machine and personal Mac.
First, I will post my code.
My data:
x = np.linspace(0,40, num=300)
noise1 = np.random.normal(0,0.3,300)
y = np.sin(x) + noise1
temp = x[150:]
noise2 = 0.004*temp**2 + np.random.normal(0,0.1,150)
y[150:] = y[150:] + noise2
true_line = np.sin(x)
true_line[150:] = true_line[150:] + 0.004*temp**2
x_sin = x[:150]
y_sin = y[:150]
X_sin = np.expand_dims(x, axis=1)
Y_sin = np.expand_dims(y, axis=1)
test_X_sin_1dim = np.linspace(-20,40,500)
test_X_sin_2dim = np.expand_dims(test_X_sin_1dim, axis=1)
plt.plot(x_sin, y_sin)
Model:
with pm.Model() as gp_model_1:
period = pm.Normal("period", mu=0, sd=10)
â_psmooth = pm.Gamma("â_psmooth ", alpha=4, beta=3)
cov_seasonal = pm.gp.cov.Periodic(1, period, â_psmooth)
gp_seasonal = pm.gp.Marginal(cov_func=cov_seasonal)
Ď = pm.HalfNormal("Ď", sd=10, testval=5)
gp = gp_seasonal
y_ = gp.marginal_likelihood("y", X=x_sin, y=y_sin, noise = Ď, shape=1)
If I run the code as is, I receive the familiar âtoo many indices for arrayâ error, which I proceed to fix by creating an additional dimension for my input by setting X=x_sin[:, None].
However, now I get the newer error of âarray must not contain infs or NaNsâ, which is strange because my two arrays do not have any infs or NaNs. Adjusting the shape parameter does nothing here.
Would anyone know what is going on?