6e79bef9961fc6ad3efeed659307c5c9aebb8d4f,tests/trainer/optimization/test_manual_optimization.py,TesManualOptimizationDDPModel,training_step,#TesManualOptimizationDDPModel#Any#Any#Any#,979
Before Change
make_manual_backward(loss_ones_gen, opt_dis, make_optimizer_step=make_dis_optimizer_step)
// this will accumulate gradients for 2 batches and then call opt_gen.step()
opt_gen.step(closure=gen_closure, make_optimizer_step=make_gen_optimizer_step)
// update discriminator every 4 baches
// therefore, no gradient accumulation for discriminator
if make_dis_optimizer_step:
After Change
make_manual_backward(loss_ones_gen, opt_dis, make_optimizer_step=make_dis_optimizer_step)
// this will accumulate gradients for 2 batches and then call opt_gen.step()
if make_gen_optimizer_step:
opt_gen.step(closure=gen_closure)
opt_gen.zero_grad()
// update discriminator every 4 baches
// therefore, no gradient accumulation for discriminator
if make_dis_optimizer_step:
opt_dis.step(closure=dis_closure)
def training_epoch_end(self, outputs) -> None:
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 3
Instances Project Name: williamFalcon/pytorch-lightning
Commit Name: 6e79bef9961fc6ad3efeed659307c5c9aebb8d4f
Time: 2021-02-16
Author: thomas@grid.ai
File Name: tests/trainer/optimization/test_manual_optimization.py
Class Name: TesManualOptimizationDDPModel
Method Name: training_step
Project Name: OpenNMT/OpenNMT-py
Commit Name: 8b287afc510ee7d6d10e3e7bf211929765ab4374
Time: 2018-08-27
Author: vince62s@yahoo.com
File Name: onmt/trainer.py
Class Name: Trainer
Method Name: _gradient_accumulation
Project Name: dmlc/gluon-cv
Commit Name: 679acab57a8e6b4117beb75913cf49acd7d9d68e
Time: 2020-10-31
Author: yizhu59@gmail.com
File Name: scripts/action-recognition/train_ddp_pytorch.py
Class Name:
Method Name: main_worker