Gradient via custom theano Op

Hello everyone,

I have multiple measurements of two real experiment ‘I’ and ‘W’ which share their inputs, and I have a simulation modelling the same experiments. I now want to fit the simulation’s parameters, such that the simulation accurately resembles the real experiments. The measurement data is given in form of multiple noisy time series and the simulation model and its gradient are available as black box functions.

To hand the black box gradients over to pymc3 I follow this example and create custom theano operations. Unfortunately these operations seem to be incredibly slow! The attached code is a simplified demo of what I’m trying to achieve. When using the (‘indirect’) theano operations the sampling process takes around 6 minutes. However using the (‘direct’) linear combination of priors the same thing takes only few seconds!

Is there something wrong in my theano operation definitions? Is there a better way to manually hand over gradients to pymc3? Any help is highly appreciated!

Michael (5.8 KB)