Skip to content

Commit dfec84d

Browse files
committed
Revert "Remove deprecated evalutate_during_training (huggingface#8852)"
This reverts commit 5530299.
1 parent 3be6c4e commit dfec84d

9 files changed

Lines changed: 12 additions & 23 deletions

File tree

examples/seq2seq/builtin_trainer/finetune.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
python finetune_trainer.py \
44
--learning_rate=3e-5 \
55
--fp16 \
6-
--do_train --do_eval --do_predict \
7-
--evaluation_strategy steps \
6+
--do_train --do_eval --do_predict --evaluate_during_training \
87
--predict_with_generate \
98
--n_val 1000 \
109
"$@"

examples/seq2seq/builtin_trainer/finetune_tpu.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ export TPU_NUM_CORES=8
55
python xla_spawn.py --num_cores $TPU_NUM_CORES \
66
finetune_trainer.py \
77
--learning_rate=3e-5 \
8-
--do_train --do_eval \
9-
--evaluation_strategy steps \
8+
--do_train --do_eval --evaluate_during_training \
109
--prediction_loss_only \
1110
--n_val 1000 \
1211
"$@"

examples/seq2seq/builtin_trainer/train_distil_marian_enro.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ python finetune_trainer.py \
1616
--num_train_epochs=6 \
1717
--save_steps 3000 --eval_steps 3000 \
1818
--max_source_length $MAX_LEN --max_target_length $MAX_LEN --val_max_target_length $MAX_LEN --test_max_target_length $MAX_LEN \
19-
--do_train --do_eval --do_predict \
20-
--evaluation_strategy steps \
19+
--do_train --do_eval --do_predict --evaluate_during_training\
2120
--predict_with_generate --logging_first_step \
2221
--task translation --label_smoothing 0.1 \
2322
"$@"

examples/seq2seq/builtin_trainer/train_distil_marian_enro_tpu.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ python xla_spawn.py --num_cores $TPU_NUM_CORES \
1717
--save_steps 500 --eval_steps 500 \
1818
--logging_first_step --logging_steps 200 \
1919
--max_source_length $MAX_LEN --max_target_length $MAX_LEN --val_max_target_length $MAX_LEN --test_max_target_length $MAX_LEN \
20-
--do_train --do_eval \
21-
--evaluation_strategy steps \
20+
--do_train --do_eval --evaluate_during_training \
2221
--prediction_loss_only \
2322
--task translation --label_smoothing 0.1 \
2423
"$@"

examples/seq2seq/builtin_trainer/train_distilbart_cnn.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ python finetune_trainer.py \
1919
--save_steps 3000 --eval_steps 3000 \
2020
--logging_first_step \
2121
--max_target_length 56 --val_max_target_length $MAX_TGT_LEN --test_max_target_length $MAX_TGT_LEN \
22-
--do_train --do_eval --do_predict \
23-
--evaluation_strategy steps \
22+
--do_train --do_eval --do_predict --evaluate_during_training \
2423
--predict_with_generate --sortish_sampler \
2524
"$@"

examples/seq2seq/builtin_trainer/train_mbart_cc25_enro.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ python finetune_trainer.py \
1515
--sortish_sampler \
1616
--num_train_epochs 6 \
1717
--save_steps 25000 --eval_steps 25000 --logging_steps 1000 \
18-
--do_train --do_eval --do_predict \
19-
--evaluation_strategy steps \
18+
--do_train --do_eval --do_predict --evaluate_during_training \
2019
--predict_with_generate --logging_first_step \
2120
--task translation \
2221
"$@"

src/transformers/integrations.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import math
33
import os
44

5-
from .trainer_utils import EvaluationStrategy
65
from .utils import logging
76

87

@@ -213,13 +212,13 @@ def _objective(trial, checkpoint_dir=None):
213212
# Check for `do_eval` and `eval_during_training` for schedulers that require intermediate reporting.
214213
if isinstance(
215214
kwargs["scheduler"], (ASHAScheduler, MedianStoppingRule, HyperBandForBOHB, PopulationBasedTraining)
216-
) and (not trainer.args.do_eval or trainer.args.evaluation_strategy == EvaluationStrategy.NO):
215+
) and (not trainer.args.do_eval or not trainer.args.evaluate_during_training):
217216
raise RuntimeError(
218217
"You are using {cls} as a scheduler but you haven't enabled evaluation during training. "
219218
"This means your trials will not report intermediate results to Ray Tune, and "
220219
"can thus not be stopped early or used to exploit other trials parameters. "
221220
"If this is what you want, do not use {cls}. If you would like to use {cls}, "
222-
"make sure you pass `do_eval=True` and `evaluation_strategy='steps'` in the "
221+
"make sure you pass `do_eval=True` and `evaluate_during_training=True` in the "
223222
"Trainer `args`.".format(cls=type(kwargs["scheduler"]).__name__)
224223
)
225224

src/transformers/trainer_tf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from .modeling_tf_utils import TFPreTrainedModel
2121
from .optimization_tf import GradientAccumulator, create_optimizer
22-
from .trainer_utils import PREFIX_CHECKPOINT_DIR, EvalPrediction, EvaluationStrategy, PredictionOutput, set_seed
22+
from .trainer_utils import PREFIX_CHECKPOINT_DIR, EvalPrediction, PredictionOutput, set_seed
2323
from .training_args_tf import TFTrainingArguments
2424
from .utils import logging
2525

@@ -561,7 +561,7 @@ def train(self) -> None:
561561

562562
if (
563563
self.args.eval_steps > 0
564-
and self.args.evaluate_strategy == EvaluationStrategy.STEPS
564+
and self.args.evaluate_during_training
565565
and self.global_step % self.args.eval_steps == 0
566566
):
567567
self.evaluate()

src/transformers/training_args_tf.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@ class TFTrainingArguments(TrainingArguments):
3434
Whether to run evaluation on the dev set or not.
3535
do_predict (:obj:`bool`, `optional`, defaults to :obj:`False`):
3636
Whether to run predictions on the test set or not.
37-
evaluation_strategy (:obj:`str` or :class:`~transformers.trainer_utils.EvaluationStrategy`, `optional`, defaults to :obj:`"no"`):
38-
The evaluation strategy to adopt during training. Possible values are:
39-
40-
* :obj:`"no"`: No evaluation is done during training.
41-
* :obj:`"steps"`: Evaluation is done (and logged) every :obj:`eval_steps`.
42-
37+
evaluate_during_training (:obj:`bool`, `optional`, defaults to :obj:`False`):
38+
Whether to run evaluation during training at each logging step or not.
4339
per_device_train_batch_size (:obj:`int`, `optional`, defaults to 8):
4440
The batch size per GPU/TPU core/CPU for training.
4541
per_device_eval_batch_size (:obj:`int`, `optional`, defaults to 8):

0 commit comments

Comments
 (0)