Are orphen nodes in a theanos computational graph a problem?

Hi Pymc3 Community,
I often use tt.set_tensor to fix values in a matrix of parameters, for example:

params = pm.Normal('params', mu=0, sd=1, shape=(3,3))
for i in range(3):
   params = tt.set_tensor(params[i,i], 0)

Now the diagnonal elements of params are “orphened” (sorry i know thats not the right word) and never connect to an observed variable. They will just sample from the prior. I’ve always assumed this is not an issue, but I wonder if there is a better way.
Another 2 ways i can think of are:

  1. Create a (3,2) shape of normals, and then place them in the off diagonals of params:
real_params = pm.Normal('params', mu=0, sd=1, shape=(3,2))
params = tt.zeros((3,3))
for i in range(3):
    for j in range(2):
            if i <= j:
                j_param = j + 1
            else:
                j_param = j
         params = tt.set_tensor(params[i,j_param], real_params[i,j])
  1. Create a (3,3) set of normals, but place a very strong and very small prior on the sd of the diagnonal elements:
params = pm.Normal('params', mu=0, sd=[[0.00001,1,1],[1,0.00001,1],[1,1,0.00001]], shape=(3,3))

All of these approaches sample just fine, but which is considered best practice?

Usually this shouldnt be an issue, unless you have something that is difficult to sample from (high dimensional, heavy tail, etc).

1 Like