Skip to content

Commit 88a0ce5

Browse files
authored
Add seed setting to image classification example (#18519)
1 parent 9129fd0 commit 88a0ce5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

examples/pytorch/image-classification/run_image_classification.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
HfArgumentParser,
4444
Trainer,
4545
TrainingArguments,
46+
set_seed,
4647
)
4748
from transformers.trainer_utils import get_last_checkpoint
4849
from transformers.utils import check_min_version, send_example_telemetry
@@ -214,6 +215,9 @@ def main():
214215
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
215216
)
216217

218+
# Set seed before initializing model.
219+
set_seed(training_args.seed)
220+
217221
# Initialize our dataset and prepare it for the 'image-classification' task.
218222
if data_args.dataset_name is not None:
219223
dataset = load_dataset(

0 commit comments

Comments
 (0)