deel.lip.utils module¶
Contains utility functions.
-
deel.lip.utils.
evaluate_lip_const
(model: tensorflow.python.keras.engine.training.Model, x, eps=0.0001, seed=None)¶ Evaluate the Lipschitz constant of a model, with the naive method. Please note that the estimation of the lipschitz constant is done locally around input sample. This may not correctly estimate the behaviour in the whole domain.
- Parameters
model – built keras model used to make predictions
x – inputs used to compute the lipschitz constant
eps – magnitude of noise to add to input in order to compute the constant
seed – seed used when generating the noise ( can be set to None )
- Returns
the empirically evaluated lipschitz constant. The computation might also be inaccurate in high dimensional space.
-
deel.lip.utils.
evaluate_lip_const_gen
(model: tensorflow.python.keras.engine.training.Model, generator: Generator[Tuple[numpy.ndarray, numpy.ndarray], Any, None], eps=0.0001, seed=None)¶ Evaluate the Lipschitz constant of a model, with the naive method. Please note that the estimation of the lipschitz constant is done locally around input sample. This may not correctly estimate the behaviour in the whole domain. The computation might also be inaccurate in high dimensional space.
This is the generator version of evaluate_lip_const.
- Parameters
model – built keras model used to make predictions
generator – used to select datapoints where to compute the lipschitz constant
eps – magnitude of noise to add to input in order to compute the constant
seed – seed used when generating the noise ( can be set to None )
- Returns
the empirically evaluated lipschitz constant.
-
deel.lip.utils.
load_model
(filepath, custom_objects=None, compile=True) → tensorflow.python.keras.engine.training.Model¶ Equivalent to load_model from keras, but custom_objects are already known
- Parameters
filepath – One of the following: - String, path to the saved model - h5py.File object from which to load the model.
custom_objects – Optional dictionary mapping names (strings) to custom classes or functions to be considered during deserialization.
compile – Boolean, whether to compile the model after loading.
- Returns
A Keras model instance. If an optimizer was found
-
deel.lip.utils.
model_from_json
(json_string, custom_objects=None) → tensorflow.python.keras.engine.training.Model¶ Equivalent to model_from_json from keras, but custom_objects are already known.
- Parameters
json_string – JSON string encoding a model configuration.
custom_objects – Optional dictionary mapping names (strings) to custom classes or functions to be considered during deserialization.
- Returns
A Keras model instance (uncompiled).
-
deel.lip.utils.
model_from_yaml
(yaml_string, custom_objects=None) → tensorflow.python.keras.engine.training.Model¶ Equivalent to model_from_json from keras, but custom_objects are already known
- Parameters
yaml_string – YAML string encoding a model configuration.
custom_objects – Optional dictionary mapping names (strings) to custom classes or functions to be considered during deserialization.
- Returns
A Keras model instance (uncompiled).