Sampler initiation stuck

Thanks a lot for your suggestion! I’ve replaced the for loop in the generate_cov function with vectorized calculations and it now looks like this. The issue remains though. The initiation stage still seems to take an infinitely long time.

def generate_cov(stddev, coords, sof):
     distance = coords[:, np.newaxis, :] - coords[np.newaxis, :, :]
     squared_norms = np.square(distance[:, :, 0]) / sof[1]**2 + np.square(distance[:, :, 1]) / sof[0]**2
     cov = stddev**2 * np.exp(-np.pi * squared_norms)
     return cov

I tried a simplified model by ignoring the dependencies of p on sof_x, sof_z, and stddev. Pymc sampler works perfectly for this simplified model.

Capture

However, whenever I sample from the full model, the initiation issue appears. I wonder would matrix factorization cause difficulties for calculating gradients or grow the computation graph in an inefficient way?
Capture1