File IO
Input Bounds
Keras Reader
- omlt.io.keras.load_keras_sequential(nn, scaling_object=None, scaled_input_bounds=None, unscaled_input_bounds=None)[source]
Load Keras sequential network.
Load a keras neural network model (built with Sequential) into an OMLT network definition object. This network definition object can be used in different formulations.
- Parameters:
nn (keras.model) – A keras model that was built with Sequential
scaling_object (instance of ScalingInterface or None) – Provide an instance of a scaling object to use to scale inputs –> scaled_inputs and scaled_outputs –> outputs. If None, no scaling is performed. See scaling.py.
scaled_input_bounds (dict or None) – A dict that contains the bounds on the scaled variables (the direct inputs to the neural network). If None, then no bounds are specified or they are generated using unscaled bounds.
unscaled_input_bounds (dict or None) – A dict that contains the bounds on the unscaled variables (the direct inputs to the neural network). If specified the scaled_input_bounds dictionary will be generated using the provided scaling object. If None, then no bounds are specified.
Returns
-------
NetworkDefinition
ONNX
- omlt.io.onnx.load_onnx_neural_network(onnx, scaling_object=None, input_bounds=None)[source]
Load a NetworkDefinition from an onnx object.
- Parameters:
onnx – onnx model
scaling_object (instance of object supporting ScalingInterface)
input_bounds (list of tuples)
Returns
-------
NetworkDefinition
- omlt.io.onnx.load_onnx_neural_network_with_bounds(filename)[source]
Load a NetworkDefinition with input bounds from an onnx object.
- Parameters:
filename (str) – the path where the ONNX model and input bounds file are written
Returns
-------
NetworkDefinition