Skip to content

Commit

Permalink
add option 'find unused paramters' for trainer (PaddlePaddle#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
LielinJiang authored May 12, 2021
1 parent 8dc8647 commit 94adf2c
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions configs/cyclegan_cityscapes.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
epochs: 200
output_dir: output_dir
find_unused_parameters: True

model:
name: CycleGANModel
Expand Down
1 change: 1 addition & 0 deletions configs/cyclegan_horse2zebra.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
epochs: 200
output_dir: output_dir
find_unused_parameters: True

model:
name: CycleGANModel
Expand Down
1 change: 1 addition & 0 deletions configs/esrgan_x4_div2k.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
total_iters: 250000
output_dir: output_dir
find_unused_parameters: True
# tensor range for function tensor2img
min_max:
(0., 1.)
Expand Down
1 change: 1 addition & 0 deletions configs/makeup.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
epochs: 100
output_dir: tmp
checkpoints_dir: checkpoints
find_unused_parameters: True

model:
name: MakeupModel
Expand Down
1 change: 1 addition & 0 deletions configs/realsr_bicubic_noise_x4_df2k.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
total_iters: 60000
output_dir: output_dir
find_unused_parameters: True
# tensor range for function tensor2img
min_max:
(0., 1.)
Expand Down
1 change: 1 addition & 0 deletions configs/realsr_kernel_noise_x4_dped.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
total_iters: 60000
output_dir: output_dir
find_unused_parameters: True
# tensor range for function tensor2img
min_max:
(0., 1.)
Expand Down
4 changes: 3 additions & 1 deletion ppgan/engine/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ def __init__(self, cfg):

def distributed_data_parallel(self):
paddle.distributed.init_parallel_env()
find_unused_parameters = self.cfg.get('find_unused_parameters', False)
for net_name, net in self.model.nets.items():
self.model.nets[net_name] = paddle.DataParallel(net)
self.model.nets[net_name] = paddle.DataParallel(
net, find_unused_parameters=find_unused_parameters)

def learning_rate_scheduler_step(self):
if isinstance(self.model.lr_scheduler, dict):
Expand Down

0 comments on commit 94adf2c

Please sign in to comment.