speechbrain.utils.seed module

Seed utilities for reproducibility.

Authors
  • Adel Moumen 2024

Summary

Functions:

seed_everything

Function that sets the seed for pseudo-random number generators in: torch, numpy, and Python's random module.

Reference

speechbrain.utils.seed.seed_everything(seed: int = 0, verbose: bool = True, deterministic: bool = False) int[source]

Function that sets the seed for pseudo-random number generators in: torch, numpy, and Python’s random module. Important note on DDP: all DDP process have the same seed. This is important to ensure that parameters without a require_grad set to True are the same across processes. This must be taken into account if one wants to build a custom data sampler as the processes would pick the same samples… SpeechBrain takes care of that internally.

Parameters:
  • seed (int) – the integer value seed for global random state.

  • verbose (bool) – Whether to print a message on each rank with the seed being set.

  • deterministic (bool) – Whether to set the seed for deterministic operations.

Returns:

The seed that was set.

Return type:

int