add_keras_constr#
- gurobi_ml.keras.keras.add_keras_constr(gp_model, keras_model, input_vars, output_vars=None, **kwargs)#
Formulate keras_model into gp_model.
The formulation predicts the values of output_vars using input_vars according to keras_model. See our Users Guide for details on the mip formulation used.
- Parameters:
gp_model (gurobipy model) – The gurobipy model where the predictor should be inserted.
keras_model (keras.Model <https://keras.io/api/models/model/>) – The keras model to insert as predictor.
input_vars (mvar_array_like) – Decision variables used as input for Keras model in gp_model.
output_vars (mvar_array_like, optional) – Decision variables used as output for Keras model in gp_model.
- Returns:
Object containing information about what was added to gp_model to formulate keras_model into it
- Return type:
- Raises:
NoModel – If the translation for some of the Keras model structure (layer or activation) is not implemented.
Notes
See
add_predictor_constr
for acceptable values for input_vars and output_vars