How can I use a theano tensor variable as a shape value

I use SBM to model network data,a IBP(indian buffet process)is used as a prior for community assignment matrix, and I want the number of communities K can be studied from data instead of predefined. When I use PyMC3 to describe my model,an error ocurred, I can’t use a theano tensor variable as a shape value

%E5%9B%BE%E7%89%87

Dynamic shape or using tensor to define shape is not possible currently. I think some of the pymc3 devs explored similar idea but none successful. @bwengals @aseyboldt?

It seems that edward support this,I’m trying.Thank you

@junpenglao Is this still not supported? What would be a work around if it’s not?

@aclam The current alternative is to have a maximum number of dimensions and then index them based on a random variable. Every variable that shows up in the trace must have fixed shape due to PyMC constraints.

Here is one example of this for a multiple point change model: Google Colab

2 Likes

@ricardoV94 Thanks a ton! This looks promising. For record, I have opened a new post here with explanation of my problem: Problem with dynamically generating random variables in a Compound Poisson model