lanl-ansi / MathOptAI.jl

Embed trained machine learning predictors in JuMP
https://lanl-ansi.github.io/MathOptAI.jl/
Other
29 stars 1 forks source link

Add Scale predictor #89

Closed odow closed 1 month ago

odow commented 1 month ago

Closes #87

cc @pulsipher

odow commented 1 month ago

@pulsipher how do you normally interact with this in OMLT? Do you manually choose the values of offset and factor?

pulsipher commented 1 month ago

See my comment in #87.

With OMLT I have manually input these which is analogous to manually specifying the weights for a dense layer, but at least this meant I didn't always have to copy and paste the same lines of code for the transformation each time.

However, as pointed out in #87, I much rather embed the preprocessing layer in the trained model and then have the scaling automatically taken care of when the predictor is built in MathOptAI. This helps avoid modelling errors and streamlines the code. Moreover, it is more practical since the data preprocessing will likely happen in Python, while MathOptAI is naturally in Julia, so accessing the scaling parameters will be more cumbersome.

odow commented 1 month ago

Okay. This PR now implements MathOptAI.Scale(scale, bias), and it adds support for Flux.Scale and Lux.Scale.