Update fish_speech/utils/__init__.py
Browse files- fish_speech/utils/__init__.py +40 -23
fish_speech/utils/__init__.py
CHANGED
|
@@ -1,23 +1,40 @@
|
|
| 1 |
-
from .braceexpand import braceexpand
|
| 2 |
-
from .context import autocast_exclude_mps
|
| 3 |
-
from .file import get_latest_checkpoint
|
| 4 |
-
from .instantiators import instantiate_callbacks, instantiate_loggers
|
| 5 |
-
from .logger import RankedLogger
|
| 6 |
-
from .logging_utils import log_hyperparameters
|
| 7 |
-
from .rich_utils import enforce_tags, print_config_tree
|
| 8 |
-
from .utils import extras, get_metric_value, task_wrapper
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .braceexpand import braceexpand
|
| 2 |
+
from .context import autocast_exclude_mps
|
| 3 |
+
from .file import get_latest_checkpoint
|
| 4 |
+
from .instantiators import instantiate_callbacks, instantiate_loggers
|
| 5 |
+
from .logger import RankedLogger
|
| 6 |
+
from .logging_utils import log_hyperparameters
|
| 7 |
+
from .rich_utils import enforce_tags, print_config_tree
|
| 8 |
+
from .utils import extras, get_metric_value, task_wrapper
|
| 9 |
+
|
| 10 |
+
def set_seed(seed: int):
|
| 11 |
+
if seed < 0:
|
| 12 |
+
seed = -seed
|
| 13 |
+
if seed > (1 << 31):
|
| 14 |
+
seed = 1 << 31
|
| 15 |
+
|
| 16 |
+
random.seed(seed)
|
| 17 |
+
np.random.seed(seed)
|
| 18 |
+
torch.manual_seed(seed)
|
| 19 |
+
|
| 20 |
+
if torch.cuda.is_available():
|
| 21 |
+
torch.cuda.manual_seed(seed)
|
| 22 |
+
torch.cuda.manual_seed_all(seed)
|
| 23 |
+
|
| 24 |
+
if torch.backends.cudnn.is_available():
|
| 25 |
+
torch.backends.cudnn.deterministic = True
|
| 26 |
+
torch.backends.cudnn.benchmark = False
|
| 27 |
+
__all__ = [
|
| 28 |
+
"enforce_tags",
|
| 29 |
+
"extras",
|
| 30 |
+
"get_metric_value",
|
| 31 |
+
"RankedLogger",
|
| 32 |
+
"instantiate_callbacks",
|
| 33 |
+
"instantiate_loggers",
|
| 34 |
+
"log_hyperparameters",
|
| 35 |
+
"print_config_tree",
|
| 36 |
+
"task_wrapper",
|
| 37 |
+
"braceexpand",
|
| 38 |
+
"get_latest_checkpoint",
|
| 39 |
+
"autocast_exclude_mps",
|
| 40 |
+
]
|