Here are my input variables:

```
X_train_hier, X_test_hier, y_train_hier, y_test_hier = train_test_split(X_hier, y, test_size=.15, random_state=seed)
X_idx = theano.shared(np.asarray(X_train_hier.uid.values))
X_user = len(np.unique(np.asarray(X.uid)))
X_train_hier = X_train_hier.drop("uid", axis=1)
X_len = len(X_train_hier.keys())
X_data = theano.shared(X_train_hier.values)
```

Here are my model:

```
with pm.Model() as hier:
#hyperpriors:
mu_a = pm.Normal("mu_a", 0.0, 1e4)
sigma_a = pm.Exponential("sigma_a", 1e4)
mu_b = pm.Normal("mu_b", 0.0, 1e4)
sigma_b = pm.Exponential("sigma_b", 1e4)
#intercept prior for each user
a = pm.Normal("a", mu_a, sigma_a, shape=X_user)
#coefficient prior for each user
b = pm.Normal("b", mu_b, sigma_b, shape=(X_len, X_user))
#likelihood
theta = pm.Deterministic("theta", pm.invlogit(tt.sum(a[X_idx] + tt.dot(X_data, b[:, X_idx]))))
#observation from sigmoid
obs = pm.Bernoulli(name="AT", p=theta, observed=y_train_hier)
```

So the model runs, and the output model is:

The real problem is when I start to sample the model:

```
with hier:
start = pm.find_MAP()
trace_hier = pm.sample(4000,
tune=4000,
init="advi+adapt_diag_grad",
start=start,
chains = 4,
random_seed=seed,
return_inferencedata=True)
```

It gives me error like this:

```
MemoryError Traceback (most recent call last)
~\AppData\Roaming\Python\Python38\site-packages\theano\compile\function\types.py in __call__(self, *args, **kwargs)
973 outputs = (
--> 974 self.fn()
975 if output_subset is None
MemoryError: failed to alloc dot22 output
During handling of the above exception, another exception occurred:
MemoryError Traceback (most recent call last)
<ipython-input-19-62b506239b95> in <module>
1 with hier:
----> 2 start = pm.find_MAP()
3 trace_hier = pm.sample(4000,
4 tune=4000,
5 init="advi+adapt_diag_grad",
~\AppData\Roaming\Python\Python38\site-packages\pymc3\tuning\starting.py in find_MAP(start, vars, method, return_raw, include_transformed, progressbar, maxeval, model, *args, **kwargs)
102 else:
103 update_start_vals(start, model.test_point, model)
--> 104 check_start_vals(start, model)
105
106 start = Point(start, model=model)
~\AppData\Roaming\Python\Python38\site-packages\pymc3\util.py in check_start_vals(start, model)
230 )
231
--> 232 initial_eval = model.check_test_point(test_point=elem)
233
234 if not np.all(np.isfinite(initial_eval)):
~\AppData\Roaming\Python\Python38\site-packages\pymc3\model.py in check_test_point(self, test_point, round_vals)
1381
1382 return Series(
-> 1383 {RV.name: np.round(RV.logp(test_point), round_vals) for RV in self.basic_RVs},
1384 name="Log-probability of test_point",
1385 )
~\AppData\Roaming\Python\Python38\site-packages\pymc3\model.py in <dictcomp>(.0)
1381
1382 return Series(
-> 1383 {RV.name: np.round(RV.logp(test_point), round_vals) for RV in self.basic_RVs},
1384 name="Log-probability of test_point",
1385 )
~\AppData\Roaming\Python\Python38\site-packages\pymc3\model.py in __call__(self, *args, **kwargs)
1558 def __call__(self, *args, **kwargs):
1559 point = Point(model=self.model, *args, **kwargs)
-> 1560 return self.f(**point)
1561
1562
~\AppData\Roaming\Python\Python38\site-packages\theano\compile\function\types.py in __call__(self, *args, **kwargs)
985 if hasattr(self.fn, "thunks"):
986 thunk = self.fn.thunks[self.fn.position_of_error]
--> 987 raise_with_op(
988 self.maker.fgraph,
989 node=self.fn.nodes[self.fn.position_of_error],
~\AppData\Roaming\Python\Python38\site-packages\theano\link\utils.py in raise_with_op(fgraph, node, thunk, exc_info, storage_map)
506 # Some exception need extra parameter in inputs. So forget the
507 # extra long error message in that case.
--> 508 raise exc_value.with_traceback(exc_trace)
509
510
~\AppData\Roaming\Python\Python38\site-packages\theano\compile\function\types.py in __call__(self, *args, **kwargs)
972 try:
973 outputs = (
--> 974 self.fn()
975 if output_subset is None
976 else self.fn(output_subset=output_subset)
MemoryError: failed to alloc dot22 output
Apply node that caused the error: Dot22(<TensorType(float64, matrix)>, InplaceDimShuffle{1,0}.0)
Toposort index: 5
Inputs types: [TensorType(float64, matrix), TensorType(float64, matrix)]
Inputs shapes: [(70345, 53), (53, 70345)]
Inputs strides: [(8, 562760), (8, 424)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[Elemwise{Add}[(0, 1)](InplaceDimShuffle{x,0}.0, Dot22.0)]]
```

I seems not able to find anything on the Internet about this “failed to alloc dot22 output” error. Can someone help me understand what went wrong in my model? Any help is appreciated!