where jm is a largeish class so I don’t include it here (but it works correctly when I e.g. set jm.B1 = 0.1 and call jm.image.eval()) it alternates between two outputs for B1:
B1 __str__ = 0.15222451156570388
B1 __str__ = nan
B1 __str__ = 0.15222451156570388
B1 __str__ = nan
B1 __str__ = 0.15222451156570388
B1 __str__ = nan
the number changes between code runs, but remains the same during a single run. Any ideas or suggestions what to try?
Seems to me the sampler is rejecting all proposal. You should not call the step directly, instead do trace = pm.sample() which use the auto initialization with multiple chain.
Then what likely happen is that the starting value is at some pathological region, which the sampler could not propose a new statue that get out from the region.
Try with other starting value (in this case using init='advi+adapt_diag' might helps).
Well, that seems unlikely, but will try. The B1 used to generate image_data is exactly in the middle of its prior (currently I test the inference on model data).
aplavin, can you please share what the error was in regard to theano broadcasting and how you fixed it. That will allow others to overcome this error if they face it in the future. Thank you
As I say, it’s not clear to me what the problem was. I fixed it with manually broadcasting two numpy arrays which were 2nd and 3rd arguments to tt.where. Everything worked correctly before this fix when I set parameters like jm.B1 = 1 and call jm.image().eval(), but somehow failed when using this with pymc. After this fix I managed to sample this model and get correct results.