Thanks. I am trying to use the scan function as follows:
cores = np.empty(self.D, dtype=object)
for d in range(self.D):
cores[d] = (sqrt_prior_covariance / np.sqrt(np.sqrt(R[d]*R[d+1]))) @ pm.Normal(f'factor_{d}',mu=0, sigma = 1, shape = (self.M,self.R[d]*self.R[d+1]))
# Model output
def tt_loop(D, X, M, cores, R):
temp = pm.math.matmul(feature_TT(X[0], M), cores[0]).reshape((R[0], R[1]))
for d in range(1, D, 1):
temp = temp @ pm.math.matmul(feature_TT(X[d], M), cores[d]).reshape((R[d], R[d + 1]))
return temp.flatten()
result, _ = pytensor.scan(fn=tt_loop,
sequences=[X],
outputs_info=None,
non_sequences=[self.D, self.M, cores, self.R])
but I am running into some problems due to how cores is defined, namely as a numpy object array (in fact I get TypeError: Unsupported dtype for TensorType: object). What is the best practice in this case?