selfclean_audio.utils.types#

Members

ensure_dictconfig

Ensure the provided configuration is an instance of DictConfig.

set_seeds

Set the random seed for reproducibility across various libraries and frameworks.

selfclean_audio.utils.types.set_seeds(_C: DictConfig)[source]#

Set the random seed for reproducibility across various libraries and frameworks.

This function sets the seed for the Python random module, the numpy library, and the torch library to ensure deterministic behavior. Additionally, it configures CuDNN’s deterministic and benchmarking behavior based on the provided configuration.

Parameters:

_C (DictConfig) – A dict configuration that contains the random seed and CuDNN settings (seed, cudnn_deterministic, and cudnn_benchmark).

Notes

  • _C.params.seed should be an integer value used for seeding.

  • _C.params.cudnn_deterministic is a boolean flag that enforces deterministic behavior in CuDNN.

  • _C.params.cudnn_benchmark is a boolean flag that enables CuDNN’s autotuner for optimal performance.

selfclean_audio.utils.types.ensure_dictconfig(_C)[source]#

Ensure the provided configuration is an instance of DictConfig.

This function checks if the given object _C is an instance of the DictConfig class. If not, a TypeError is raised.

Parameters:

_C (object) – The configuration object to check.

Returns:

The original _C object if it is an instance of DictConfig.

Return type:

DictConfig

Raises:

TypeError – If _C is not an instance of DictConfig.