# GaussianRandomWalk from the example notebook errors out with ValueError: Input dimension mis-match

**URL:** https://discourse.pymc.io/t/gaussianrandomwalk-from-the-example-notebook-errors-out-with-valueerror-input-dimension-mis-match/6327
**Category:** Questions
**Created:** [November 30, 2020, 5:56am UTC](https://discourse.pymc.io/t/gaussianrandomwalk-from-the-example-notebook-errors-out-with-valueerror-input-dimension-mis-match/6327 "2020-11-30T05:56:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![gunrr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/gunrr/32/3375_2.png) [@gunrr](https://discourse.pymc.io/u/gunrr)
#### Post date: [November 30, 2020, 5:56am UTC](https://discourse.pymc.io/t/gaussianrandomwalk-from-the-example-notebook-errors-out-with-valueerror-input-dimension-mis-match/6327/1 "2020-11-30T05:56:15Z")

</div>

I am experimenting with the code from [https://github.com/twiecki/WhileMyMCMCGentlySamples/blob/master/content/downloads/notebooks/random\_walk\_deep\_net.ipynb](https://github.com/twiecki/WhileMyMCMCGentlySamples/blob/master/content/downloads/notebooks/random_walk_deep_net.ipynb) but the GaussianRandomWalk line errors out with ‘ValueError: Input dimension mis-match. (input[0].shape[1] = 1, input[1].shape[1] = 2)’. Can someone let me know what I’m missing or if there’s any updated notebooks. I installed pymc with conda forge command and there are no import issues.

## Detailed log :

ValueError Traceback (most recent call last)  
 in   
8  
9 # This is the central trick, PyMC3 already comes with this distribution  
—\> 10 w = pm.GaussianRandomWalk(‘w’, sd=step\_size,  
11 shape=(interval, 2))  
12

D:\Softwares\Anaconda3\lib\site-packages\pymc3\distributions\distribution.py in **new** (cls, name, \*args, \*\*kwargs)  
45 total\_size = kwargs.pop(‘total\_size’, None)  
46 dist = cls.dist(\*args, \*\*kwargs)  
—\> 47 return model.Var(name, dist, data, total\_size)  
48 else:  
49 raise TypeError(“Name needs to be a string but got: {}”.format(name))

D:\Softwares\Anaconda3\lib\site-packages\pymc3\model.py in Var(self, name, dist, data, total\_size)  
919 if getattr(dist, “transform”, None) is None:  
920 with self:  
–\> 921 var = FreeRV(name=name, distribution=dist,  
922 total\_size=total\_size, model=self)  
923 self.free\_RVs.append(var)

D:\Softwares\Anaconda3\lib\site-packages\pymc3\model.py in **init** (self, type, owner, index, name, distribution, total\_size, model)  
1368 self.tag.test\_value = np.ones(  
1369 distribution.shape, distribution.dtype) \* distribution.default()  
-\> 1370 self.logp\_elemwiset = distribution.logp(self)  
1371 # The logp might need scaling in minibatches.  
1372 # This is done in `Factor`.

D:\Softwares\Anaconda3\lib\site-packages\pymc3\distributions\timeseries.py in logp(self, x)  
230 x\_i = x[1:]  
231 mu, sigma = self.\_mu\_and\_sigma(self.mu, self.sigma)  
–\> 232 innov\_like = Normal.dist(mu=x\_im1 + mu, sigma=sigma).logp(x\_i)  
233 return self.init.logp(x[0]) + tt.sum(innov\_like)  
234 return self.init.logp(x)

D:\Softwares\Anaconda3\lib\site-packages\pymc3\distributions\continuous.py in logp(self, value)  
516 mu = self.mu  
517  
–\> 518 return bound((-tau \* (value - mu)\*\*2 + tt.log(tau / np.pi / 2.)) / 2.,  
519 sigma \> 0)  
520

D:\Softwares\Anaconda3\lib\site-packages\theano\tensor\var.py in **mul** (self, other)  
153 # and the return value in that case  
154 try:  
–\> 155 return theano.tensor.mul(self, other)  
156 except (NotImplementedError, AsTensorError):  
157 return NotImplemented

D:\Softwares\Anaconda3\lib\site-packages\theano\gof\op.py in **call** (self, \*inputs, \*\*kwargs)  
672 thunk.outputs = [storage\_map[v] for v in node.outputs]  
673  
–\> 674 required = thunk()  
675 assert not required # We provided all inputs  
676

D:\Softwares\Anaconda3\lib\site-packages\theano\gof\op.py in rval()  
860  
861 def rval():  
–\> 862 thunk()  
863 for o in node.outputs:  
864 compute\_map[o][0] = True

D:\Softwares\Anaconda3\lib\site-packages\theano\gof\cc.py in **call** (self)  
1737 print(self.error\_storage, file=sys.stderr)  
1738 raise  
-\> 1739 reraise(exc\_type, exc\_value, exc\_trace)  
1740  
1741

D:\Softwares\Anaconda3\lib\site-packages\six.py in reraise(tp, value, tb)  
701 if value. **traceback** is not tb:  
702 raise value.with\_traceback(tb)  
–\> 703 raise value  
704 finally:  
705 value = None

ValueError: Input dimension mis-match. (input[0].shape[1] = 1, input[1].shape[1] = 2)

Any help is appreciated. Thanks.

---

<div class="post-metadata">

### Author: ![luisroque](https://avatars.discourse-cdn.com/v4/letter/l/7c8e57/32.png) [@luisroque](https://discourse.pymc.io/u/luisroque)
#### Post date: [November 30, 2020, 3:48pm UTC](https://discourse.pymc.io/t/gaussianrandomwalk-from-the-example-notebook-errors-out-with-valueerror-input-dimension-mis-match/6327/2 "2020-11-30T15:48:48Z")

</div>

Hmmm, the problem seems to be in the step\_size shape. I would just make it into a matrix with (1, n\_dim) but it is not broadcasting I don’t know why.

Nevertheless, I just reshaped a bit to ensure that the shapes matched and it works.

```auto
step_size = pm.HalfNormal('step_size', 
                              sd=np.ones(n_dim), 
                              shape=(1,n_dim))
step_size_ = tt.tile(step_size, (interval,1))

# This is the central trick, PyMC3 already comes with this distribution
w = pm.GaussianRandomWalk('w', sd=step_size_, 
                              shape=(interval, 2))

```

Hope it helps!

---

<div class="post-metadata">

### Author: ![gunrr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/gunrr/32/3375_2.png) [@gunrr](https://discourse.pymc.io/u/gunrr)
#### Post date: [December 8, 2020, 10:30pm UTC](https://discourse.pymc.io/t/gaussianrandomwalk-from-the-example-notebook-errors-out-with-valueerror-input-dimension-mis-match/6327/3 "2020-12-08T22:30:42Z")

</div>

Apologies for the late response. This one works. Thank you very much!
