Pyomo / pyomo

An object-oriented algebraic modeling language in Python for structured optimization problems.
https://www.pyomo.org
Other
2.01k stars 518 forks source link

How to optimize ann model using pyomo? #2113

Closed wangyexiang closed 1 year ago

wangyexiang commented 3 years ago

Thanks in advance!

blnicho commented 3 years ago

Based on the error I think your problem is that the model coming back from tensorflow is using intrinsic functions coming from Python or Numpy instead of the ones provided by Pyomo. You need to either convert the model to explicit Pyomo expression trees or treat the model as an external function/blackbox. I think there are some general tools under development for doing exactly this but I'm not sure if they have been released yet.

wangyexiang commented 3 years ago

treat the model as an external function/blackbox.

Dear sir, Thank for your reply. Is external function/blackbox mean pyomo.core.expr.current.ExternalFunction? If yes, could you give me an example about how to use ExternalFunction API to optimize a machine learning model?Thanks in advance!@blnicho

blnicho commented 1 year ago

@wangyexiang there is a new package out called OMLT for representing machine learning models within a Pyomo model. You can find it here: https://github.com/cog-imperial/OMLT