Download callbacks.py from Check/vaw2tmp: direct link, hf CLI and curl.
- Browser
- Download file 553 Bytes
-
https://huggingface.co/Check/vaw2tmp/resolve/c8de7932c51e4e4a1efd987e1ca58e6ebb37d1eb/callbacks.py
- Command line
-
hf download hf://Check/vaw2tmp@c8de7932c51e4e4a1efd987e1ca58e6ebb37d1eb/callbacks.py
-
curl -L -o callbacks.py https://huggingface.co/Check/vaw2tmp/resolve/c8de7932c51e4e4a1efd987e1ca58e6ebb37d1eb/callbacks.py
553 Bytes
| from transformers import TrainerCallback, TrainingArguments, TrainerState, TrainerControl, logging | |
| class BreakEachEpoch(TrainerCallback): | |
| """ | |
| A :class:`~transformers.TrainerCallback` that handles the default flow of the training loop for logs, evaluation | |
| and checkpoints. | |
| """ | |
| def on_epoch_end(self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs): | |
| control.should_training_stop = True | |
| logging.get_logger().info("Break each epoch for reload new shard dataset") | |
| return control | |