##
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: inputs, targets = batch outputs = model(inputs) loss = loss_function(outputs, targets) + accelerator.log({"loss":loss}) accelerator.backward(loss) optimizer.step() scheduler.step() optimizer.zero_grad() +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: - Using experiment trackers - Accelerator API Reference - Tracking API Reference