Aan de slagGa gratis aan de slag

Save and load the state of preprocessed text

You've finished preprocessing a dataset of agricultural questions and answers to help farmers look up common issues in the field. To save your progress, you decide to create and load checkpoints of the preprocessed text data.

Some data has been preloaded:

  • dataloader contains a preprocessed dataset of agricultural questions and answers
  • Accelerator has been imported from accelerate

Deze oefening maakt deel uit van de cursus

Efficient AI Model Training with PyTorch

Cursus bekijken

Oefeninstructies

  • Save a checkpoint of the preprocessed data in checkpoint_dir.
  • Load a checkpoint from checkpoint_dir.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

accelerator = Accelerator()

dataloader = accelerator.prepare(dataloader)

checkpoint_dir = Path("preprocess_checkpoint")

# Save a checkpoint of the data
____.____(checkpoint_dir)

# Load from the checkpoint
____.____(checkpoint_dir)
Code bewerken en uitvoeren