Skip to content

Commit

Permalink
[examples] upgrade code for seed setting (#3387)
Browse files Browse the repository at this point in the history
* replace set_seed

* update import
  • Loading branch information
faaany authored Feb 11, 2025
1 parent 5cc99e6 commit 24f8d02
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions examples/cv_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor

from accelerate import Accelerator
from accelerate.utils import set_seed


########################################################################
Expand Down Expand Up @@ -93,10 +94,7 @@ def training_function(config, args):
label_to_id = {lbl: i for i, lbl in enumerate(id_to_label)}

# Set the seed before splitting the data.
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)

set_seed(seed)
# Split our filenames between train and validation
random_perm = np.random.permutation(len(file_names))
cut = int(0.8 * len(file_names))
Expand Down

0 comments on commit 24f8d02

Please sign in to comment.