sparseml.keras package

Subpackages

Submodules

sparseml.keras.base module

sparseml.keras.base.check_keras2onnx_install(min_version: Optional[str] = '1.0.0', max_version: Optional[str] = None, raise_on_error: bool = True)bool[source]

Check that the keras2onnx package is installed. If raise_on_error, will raise an ImportError if it is not installed or the required version range, if set, is not installed. If not raise_on_error, will return True if installed with required version and False otherwise.

Parameters
  • min_version (str) – The minimum version for keras2onnx that it must be greater than or equal to, if unset will require no minimum version

  • max_version (str) – The maximum version for keras2onnx that it must be less than or equal to, if unset will require no maximum version.

  • raise_on_error (bool) – True to raise any issues such as not installed, minimum version, or maximum version as ImportError. False to return the result.

Returns

If raise_on_error, will return False if keras2onnx is not installed or the version is outside the accepted bounds and True if everything is correct.

Return type

bool

sparseml.keras.base.check_keras_install(min_tf_version: Optional[str] = '2.1.0', max_tf_version: Optional[str] = None, min_native_version: Optional[str] = '2.4.3', require_tensorflow_backend: bool = True, raise_on_error: bool = True)bool[source]

Check that the keras package is installed. If raise_on_error, will raise an ImportError if it is not installed or the required version range, if set, is not installed. If not raise_on_error, will return True if installed with required version and False otherwise.

Parameters
  • min_tf_version (str) – The minimum version for keras that it must be greater than or equal to, if unset will require no minimum version

  • max_tf_version (str) – The maximum version for keras that it must be less than or equal to, if unset will require no maximum version.

  • min_native_version (str) – The minimum version for native keras that it must be greater than or equal to if installed

  • require_tensorflow_backend (bool) – True to require keras to use the tensorflow backend, False otherwise.

  • raise_on_error (bool) – True to raise any issues such as not installed, minimum version, or maximum version as ImportError. False to return the result.

Returns

If raise_on_error, will return False if keras is not installed or the version is outside the accepted bounds and True if everything is correct.

Return type

bool

sparseml.keras.base.require_keras(min_tf_version: Optional[str] = '2.1.0', max_tf_version: Optional[str] = None, min_native_version: Optional[str] = '2.4.3', require_tensorflow_backend: bool = True)[source]

Decorator function to require use of keras. Will check that keras package is installed and within the bounding ranges of min_version and max_version if they are set before calling the wrapped function. See check_keras_install() for more info.

Parameters
  • min_tf_version (str) – The minimum version for keras that it must be greater than or equal to, if unset will require no minimum version

  • max_tf_version (str) – The maximum version for keras that it must be less than or equal to, if unset will require no maximum version.

  • min_native_version (str) – The minimum version for native keras that it must be greater than or equal to if installed

  • require_tensorflow_backend (bool) – True to require keras to use the tensorflow backend, False otherwise.

  • require_tensorflow_backend – True to require keras to use the tensorflow backend, False otherwise.

sparseml.keras.base.require_keras2onnx(min_version: Optional[str] = '1.0.0', max_version: Optional[str] = None)[source]

Decorator function to require use of keras2onnx. Will check that keras2onnx package is installed and within the bounding ranges of min_version and max_version if they are set before calling the wrapped function. See check_keras2onnx_install() for more info.

param min_version: The minimum version for keras2onnx that it must be greater than

or equal to, if unset will require no minimum version

Parameters

max_version (str) – The maximum version for keras2onnx that it must be less than or equal to, if unset will require no maximum version.

Module contents

Functionality for working with and sparsifying Models in the Keras framework