# Length of Elemwise{sub,no_inplace}.0 cannot be determined Error

Length of Elemwise{sub,no_inplace}.0 cannot be determined

i’ve already convert my input ( with shape (901,1) ) into numpy array as ValueError: length not known: Elemwise - Questions - PyMC Discourse, but still not able to figure it out.

Here is how i create my GP model.

with pm.Model() as model: # prior ℓ and η

ℓ = pm.Gamma(“ℓ”, alpha=1, beta=2)
alp = pm.Gamma(“alp”, alpha=1, beta=2)
η = pm.Gamma(“η”, mu=1, sigma=2) #

cov = η * pm.gp.cov.RatQuad(N, alpha=alp, ls=ℓ)
gp = pm.gp.MarginalSparse(cov_func=cov, approx=“FITC”)

Xu = pm.gp.util.kmeans_inducing_points(_induced_point, X_train_normalized)

σ = pm.Gamma(“σ”, alpha=1, beta=2) #
y_ = gp.marginal_likelihood(“y”, X=X_train_normalized, Xu=Xu, y=y_train, noise=σ)

mp = pm.sample(draws=100, tune=100, cores=1)

with model:
test_result = gp.conditional(“x_test”, X_new)
result = gp.conditional(“result”, np.array(tau).reshape(-1,1))

and here is the full trace error,

ValueError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_15588\953747960.py in
1 # add the GP conditional to the model, given the new X values
2 with model:
----> 3 test_result = gp.conditional(“x_test”, X_new)
4 result = gp.conditional(“result”, np.array(tau).reshape(-1,1))
5

~\anaconda3\envs\pymc3_env\lib\site-packages\pymc3\gp\gp.py in conditional(self, name, Xnew, pred_noise, given, **kwargs)
816
817 givens = self._get_given_vals(given)
→ 818 mu, cov = self._build_conditional(Xnew, pred_noise, False, *givens)
819 shape = infer_shape(Xnew, kwargs.pop(“shape”, None))
820 return pm.MvNormal(name, mu=mu, cov=cov, shape=shape, **kwargs)

~\anaconda3\envs\pymc3_env\lib\site-packages\pymc3\gp\gp.py in _build_conditional(self, Xnew, pred_noise, diag, X, Xu, y, sigma, cov_total, mean_total)
757 A_l = A / Lamd
758 L_B = cholesky(tt.eye(Xu.shape[0]) + tt.dot(A_l, tt.transpose(A)))
→ 759 r = y - mean_total(X)
760 r_l = r / Lamd
761 c = solve_lower(L_B, tt.dot(A, r_l))

~\anaconda3\envs\pymc3_env\lib\site-packages\pandas\core\ops\common.py in new_method(self, other)
67 other = item_from_zerodim(other)
68
—> 69 return method(self, other)
70
71 return new_method

~\anaconda3\envs\pymc3_env\lib\site-packages\pandas\core\arraylike.py in sub(self, other)
98 @unpack_zerodim_and_defer(“sub”)
99 def sub(self, other):
→ 100 return self._arith_method(other, operator.sub)
101
102 @unpack_zerodim_and_defer(“rsub”)

~\anaconda3\envs\pymc3_env\lib\site-packages\pandas\core\series.py in _arith_method(self, other, op)
5526 result = ops.arithmetic_op(lvalues, rvalues, op)
5527
→ 5528 return self._construct_result(result, name=res_name)
5529
5530

~\anaconda3\envs\pymc3_env\lib\site-packages\pandas\core\series.py in _construct_result(self, result, name)
2943 # We do not pass dtype to ensure that the Series constructor
2944 # does inference in the case where `result` has object-dtype.
→ 2945 out = self._constructor(result, index=self.index)
2946 out = out.finalize(self)
2947

~\anaconda3\envs\pymc3_env\lib\site-packages\pandas\core\series.py in init(self, data, index, dtype, name, copy, fastpath)
421 pass
422 else:
→ 423 data = com.maybe_iterable_to_list(data)
424
425 if index is None:

~\anaconda3\envs\pymc3_env\lib\site-packages\pandas\core\common.py in maybe_iterable_to_list(obj)
290 “”"
291 if isinstance(obj, abc.Iterable) and not isinstance(obj, abc.Sized):
→ 292 return list(obj)
293 obj = cast(Collection, obj)
294 return obj

~\anaconda3\envs\pymc3_env\lib\site-packages\theano\tensor\var.py in iter(self)
634 def iter(self):
635 try:
→ 636 for i in range(theano.tensor.basic.get_vector_length(self)):
637 yield self[i]
638 except TypeError:

~\anaconda3\envs\pymc3_env\lib\site-packages\theano\tensor\basic.py in get_vector_length(v)
4889 raise ValueError(f"Length of {v} cannot be determined")
4890
→ 4891 raise ValueError(f"Length of {v} cannot be determined")
4892
4893

ValueError: Length of Elemwise{sub,no_inplace}.0 cannot be determined