Stochastic optimization problem, ValueError

This is happening because you are mixing numpy and aesara operations. pm.Deterministic expects an aesara tensor, but you are giving it a numpy array (np.ndarray.copy takes a string that defines the storage format of the array, while aesara.tensor.copy takes a string that defines the name of the symbol tensor object, hence the error).

If you want to use a scipy optimizer inside your model, you will need to wrap it into an aesara Op. Full docs on Ops are here, and an example inside a PyMC model can be found here.

Basically you need to tell it what datatypes and shapes to expect as inputs and outputs, then put your lp_solve code inside the perform method.

Note that doing this will not allow you to use NUTS, because your Op won’t have a gradient (unless you give it one).

2 Likes