Closed
Description
Description of your problem
The y
argument to Latent.marginal_likelihood
is just forwarded into self.y
.
Later in the workflow, when attempting to make conditional observations this leads to a traceback that does not immediately make it obvious what the problem was.
Converting the y
to a numpy array or pm.Data
container solves the problem.
Traceback from my debugging
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-169-dfcf8011ab79> in <module>
1 givens = gp._get_given_vals(None)
----> 2 gp._build_conditional(
3 X_denses["D0"],
4 False,
5 False,
~\AppData\Local\Continuum\miniconda3\envs\CARenv\lib\site-packages\pymc3\gp\gp.py in _build_conditional(self, Xnew, pred_noise, diag, X, y, noise, cov_total, mean_total)
472 Kxs = self.cov_func(X, Xnew)
473 Knx = noise(X)
--> 474 rxx = y - mean_total(X)
475 L = cholesky(stabilize(Kxx) + Knx)
476 A = solve_lower(L, Kxs)
~\AppData\Local\Continuum\miniconda3\envs\CARenv\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
~\AppData\Local\Continuum\miniconda3\envs\CARenv\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__")
~\AppData\Local\Continuum\miniconda3\envs\CARenv\lib\site-packages\pandas\core\series.py in _arith_method(self, other, op)
5525 result = ops.arithmetic_op(lvalues, rvalues, op)
5526
-> 5527 return self._construct_result(result, name=res_name)
5528
5529
~\AppData\Local\Continuum\miniconda3\envs\CARenv\lib\site-packages\pandas\core\series.py in _construct_result(self, result, name)
2942 # We do not pass dtype to ensure that the Series constructor
2943 # does inference in the case where `result` has object-dtype.
-> 2944 out = self._constructor(result, index=self.index)
2945 out = out.__finalize__(self)
2946
~\AppData\Local\Continuum\miniconda3\envs\CARenv\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:
~\AppData\Local\Continuum\miniconda3\envs\CARenv\lib\site-packages\pandas\core\common.py in maybe_iterable_to_list(obj)
286 """
287 if isinstance(obj, abc.Iterable) and not isinstance(obj, abc.Sized):
--> 288 return list(obj)
289 obj = cast(Collection, obj)
290 return obj
~\AppData\Local\Continuum\miniconda3\envs\CARenv\lib\site-packages\aesara\tensor\var.py in __iter__(self)
637 def __iter__(self):
638 try:
--> 639 for i in range(aet.basic.get_vector_length(self)):
640 yield self[i]
641 except TypeError:
~\AppData\Local\Continuum\miniconda3\envs\CARenv\lib\site-packages\aesara\tensor\basic.py in get_vector_length(v)
2832 raise ValueError(f"Length of {v} cannot be determined")
2833
-> 2834 raise ValueError(f"Length of {v} cannot be determined")
2835
2836
ValueError: Length of Elemwise{sub,no_inplace}.0 cannot be determined
Possible solutions
- Raise an error unless
y
is a numpy array or tensor - Automatically convert it
Versions and main components
- PyMC3 Version:
main