thenativefox
Added split files and tables
939262b
raw
history blame contribute delete
442 Bytes
Backward
The last addition is to replace the typical loss.backward() in your training loop with πŸ€— Accelerate's [~accelerate.Accelerator.backward]method:
for epoch in range(num_epochs):
for batch in train_dataloader:
outputs = model(**batch)
loss = outputs.loss
accelerator.backward(loss)
optimizer.step()
lr_scheduler.step()
optimizer.zero_grad()
progress_bar.update(1)