Thanks for the reply! Yes, the gradient also depends on information from the external program.
Why wouldn’t Theano allow that, if the functions themselves are allowed to call external programs? I would think it’s usually the case that the gradient has similar dependencies as the function. But Theano is still very much a black box to me.
Can you think of any workaround?