From f40b718959b496c797da8dfa17194b63858fc2b1 Mon Sep 17 00:00:00 2001 From: flybird1111 <1829166702@qq.com> Date: Fri, 4 Aug 2023 17:24:35 +0800 Subject: [PATCH] [doc] Fix gradient accumulation doc. (#4349) * [doc] fix gradient accumulation doc * [doc] fix gradient accumulation doc --- docs/source/en/features/gradient_accumulation_with_booster.md | 2 ++ .../zh-Hans/features/gradient_accumulation_with_booster.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/docs/source/en/features/gradient_accumulation_with_booster.md b/docs/source/en/features/gradient_accumulation_with_booster.md index 201e3bc2b..7bc4eb47b 100644 --- a/docs/source/en/features/gradient_accumulation_with_booster.md +++ b/docs/source/en/features/gradient_accumulation_with_booster.md @@ -103,10 +103,12 @@ for idx, (img, label) in enumerate(train_dataloader): with sync_context: output = model(img) train_loss = criterion(output, label) + train_loss = train_loss / GRADIENT_ACCUMULATION booster.backward(train_loss, optimizer) else: output = model(img) train_loss = criterion(output, label) + train_loss = train_loss / GRADIENT_ACCUMULATION booster.backward(train_loss, optimizer) optimizer.step() optimizer.zero_grad() diff --git a/docs/source/zh-Hans/features/gradient_accumulation_with_booster.md b/docs/source/zh-Hans/features/gradient_accumulation_with_booster.md index a8422060f..d121b161b 100644 --- a/docs/source/zh-Hans/features/gradient_accumulation_with_booster.md +++ b/docs/source/zh-Hans/features/gradient_accumulation_with_booster.md @@ -106,10 +106,12 @@ for idx, (img, label) in enumerate(train_dataloader): with sync_context: output = model(img) train_loss = criterion(output, label) + train_loss = train_loss / GRADIENT_ACCUMULATION booster.backward(train_loss, optimizer) else: output = model(img) train_loss = criterion(output, label) + train_loss = train_loss / GRADIENT_ACCUMULATION booster.backward(train_loss, optimizer) optimizer.step() optimizer.zero_grad()