Setting up a multiple input multiple output regularized Bayesian regression

I appreciate the help with this! When running your script I get the following TypeError:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/usr/local/lib/python3.8/site-packages/theano/tensor/type.py in dtype_specs(self)
    264         try:
--> 265             return {
    266                 "float16": (float, "npy_float16", "NPY_FLOAT16"),

KeyError: 'object'

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-14-b744de5862b4> in <module>
     28     # with A is only because of the shape we set up earlier for x.
     29     pm.Normal('x_end', mu=x[0:-1]@A, observed=x[1:], sd=error_sd)
---> 30     pm.Potential('A_penalty', frobenius_norm(A) * penalty_weight)
     31 
     32     trace = pm.sample()

<ipython-input-14-b744de5862b4> in frobenius_norm(X)
      1 def frobenius_norm(X):
----> 2     return tt.sum(tt.nlinalg.trace(A@A.T))**0.5
      3 
      4 # Create simulated data via forward evolution of system
      5 K        = 3

/usr/local/lib/python3.8/site-packages/theano/tensor/nlinalg.py in trace(X)
    232 
    233     """
--> 234     return extract_diag(X).sum()
    235 
    236 

/usr/local/lib/python3.8/site-packages/theano/graph/op.py in __call__(self, *inputs, **kwargs)
    248         """
    249         return_list = kwargs.pop("return_list", False)
--> 250         node = self.make_node(*inputs, **kwargs)
    251 
    252         if config.compute_test_value != "off":

/usr/local/lib/python3.8/site-packages/theano/tensor/basic.py in make_node(self, x)
   6563 
   6564     def make_node(self, x):
-> 6565         x = as_tensor_variable(x)
   6566 
   6567         if x.ndim < 2:

/usr/local/lib/python3.8/site-packages/theano/tensor/basic.py in as_tensor_variable(x, name, ndim)
    205         )
    206 
--> 207     return constant(x, name=name, ndim=ndim)
    208 
    209 

/usr/local/lib/python3.8/site-packages/theano/tensor/basic.py in constant(x, name, ndim, dtype)
    253         assert x_.ndim == ndim
    254 
--> 255     ttype = TensorType(dtype=x_.dtype, broadcastable=[s == 1 for s in x_.shape])
    256 
    257     try:

/usr/local/lib/python3.8/site-packages/theano/tensor/type.py in __init__(self, dtype, broadcastable, name, sparse_grad)
     52         # True or False
     53         self.broadcastable = tuple(bool(b) for b in broadcastable)
---> 54         self.dtype_specs()  # error checking is done there
     55         self.name = name
     56         self.numpy_dtype = np.dtype(self.dtype)

/usr/local/lib/python3.8/site-packages/theano/tensor/type.py in dtype_specs(self)
    280             }[self.dtype]
    281         except KeyError:
--> 282             raise TypeError(
    283                 f"Unsupported dtype for {self.__class__.__name__}: {self.dtype}"
    284             )

TypeError: Unsupported dtype for TensorType: object

Would you be able to help with this error? It’s not something I have encountered prior.

Edit: I wanted to add that the error arises when calling frobenius_norm on the symbolic matrix A