##
from accelerate import Accelerator -accelerator = Accelerator() +accelerator = Accelerator(log_with="wandb") train_dataloader, model, optimizer scheduler = accelerator.prepare( dataloader, model, optimizer, scheduler ) +accelerator.init_trackers() model.train() for batch in train_dataloader: optimizer.zero_grad() inputs, targets = batch outputs = model(inputs) loss = loss_function(outputs, targets) + accelerator.log({"loss":loss}) accelerator.backward(loss) optimizer.step() scheduler.step() +accelerator.end_training()## To use experiment trackers with `accelerate`, simply pass the desired tracker to the `log_with` parameter when building the `Accelerator` object. Then initialize the tracker(s) by running `Accelerator.init_trackers()` passing in any configurations they may need. Afterwards call `Accelerator.log` to log a particular value to your tracker. At the end of training call `accelerator.end_training()` to call any finalization functions a tracking library may need automatically. ## To learn more checkout the related documentation: - [Basic Tutorial](https://huggingface.co/docs/accelerate/usage_guides/tracking) - [Accelerator API Reference](https://huggingface.co/docs/accelerate/package_reference/accelerator#accelerate.Accelerator.log) - [Tracking API Reference](https://huggingface.co/docs/accelerate/package_reference/tracking)