# 2d classification with GP, problem

**URL:** <https://discourse.pymc.io/t/2d-classification-with-gp-problem/102>\
**Category:** Questions\
**Created:** [June 19, 2017, 12:05pm UTC](https://discourse.pymc.io/t/2d-classification-with-gp-problem/102 "2017-06-19T12:05:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Namenaro](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@Namenaro](https://discourse.pymc.io/u/Namenaro)\
**Post date:** [June 19, 2017, 12:05pm UTC](https://discourse.pymc.io/t/2d-classification-with-gp-problem/102/1 "2017-06-19T12:05:28Z")

</div>

Hi. GP creation is falling when I try to make it with not-1d input space:

```
import pymc3 as pm
import numpy as np
from sklearn.datasets.samples_generator import make_moons

X, Y = make_moons(noise=0.2, random_state=0, n_samples=15)
with pm.Model() as GP:
    l = np.array([0.2, 1.0])
    K = pm.gp.cov.ExpQuad(input_dim=2, lengthscales=l)
    M = pm.gp.mean.Zero()
    s = pm.HalfCauchy('s', 2.5)
    y_obs = pm.gp.GP('y_obs', mean_func=M, cov_func=K, sigma=s, observed={'X': X, 'Y': Y})

```

The error is happening in the last line:

> log\_thunk\_trace: There was a problem executing an Op.  
> Traceback (most recent call last):  
> File “C:/Users/neuro/PycharmProjects/share\_spec/gaussian\_process.py”, line 13, in   
> y\_obs = pm.gp.GP(‘y\_obs’, mean\_func=M, cov\_func=K, sigma=s, observed={‘X’: X, ‘Y’: Y})  
> File “C:\Users\neuro\Anaconda2\lib\site-packages\pymc3\distributions\distribution.py”, line 39, in **new**  
> return model.Var(name, dist, data, total\_size)  
> File “C:\Users\neuro\Anaconda2\lib\site-packages\pymc3\model.py”, line 534, in Var  
> total\_size=total\_size, model=self)  
> File “C:\Users\neuro\Anaconda2\lib\site-packages\pymc3\model.py”, line 1018, in **init**  
> self.logp\_elemwiset = distribution.logp(\*\*self.data)  
> File “C:\Users\neuro\Anaconda2\lib\site-packages\pymc3\gp\gp.py”, line 76, in logp  
> return MvNormal.dist(mu, Sigma).logp(Y)  
> File “C:\Users\neuro\Anaconda2\lib\site-packages\pymc3\distributions\multivariate.py”, line 200, in logp  
> delta = value - mu  
> File “C:\Users\neuro\Anaconda2\lib\site-packages\theano\tensor\var.py”, line 147, in **sub**  
> return theano.tensor.basic.sub(self, other)  
> File “C:\Users\neuro\Anaconda2\lib\site-packages\theano\gof\op.py”, line 674, in **call**  
> required = thunk()  
> File “C:\Users\neuro\Anaconda2\lib\site-packages\theano\gof\op.py”, line 843, in rval  
> fill\_storage()  
> File “C:\Users\neuro\Anaconda2\lib\site-packages\theano\gof\cc.py”, line 1698, in **call**  
> reraise(exc\_type, exc\_value, exc\_trace)  
> File “”, line 2, in reraise  
> ValueError: Input dimension mis-match. (input[0].shape[1] = 15, input[1].shape[1] = 2)

Am I doing smth wrong?

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [June 19, 2017, 12:35pm UTC](https://discourse.pymc.io/t/2d-classification-with-gp-problem/102/2 "2017-06-19T12:35:03Z")

</div>

Thanks for reporting! There is a bug in the `gp.mean` that [the fix is still waiting to merge](https://github.com/pymc-devs/pymc3/pull/2111).

Currently, a workaround is to use `pm.MvNormal` directly:

```python
Sigma = K(X) + tt.eye(X.shape[0])*s**2
y_obs = pm.MvNormal('y_obs', mu=0, cov=Sigma, observed=Y)

```

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [June 21, 2017, 11:15am UTC](https://discourse.pymc.io/t/2d-classification-with-gp-problem/102/3 "2017-06-21T11:15:26Z")

</div>

@Namenaro The fix is just merge - if you upgrade to master your code will work now 😉
