Spaces:
Sleeping
Sleeping
File size: 518 Bytes
45311fe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import torch
import random
import numpy as np
from transformers.utils import (
is_tf_available,
is_torch_available,
)
def set_seed(seed_value: int):
"""
Helper function for reproducible behavior to set the seed in `random`, `numpy`, `torch` and/or `tf` (if installed).
Args:
seed (`int`): The seed to set.
"""
random.seed(seed_value)
np.random.seed(seed_value)
if is_torch_available():
torch.manual_seed(seed_value)
torch.cuda.manual_seed_all(seed_value)
|