Skip to content

Commit

Permalink
Minor refine
Browse files Browse the repository at this point in the history
  • Loading branch information
HAOCHENYE committed Mar 5, 2024
1 parent 3661fbd commit 149b950
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/test_optim/test_optimizer/test_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,12 +592,16 @@ def test_default_optimizer_constructor_no_grad(self):
dwconv_decay_mult=0.1,
dcn_offset_lr_mult=0.1)

for param in self.model.parameters():
param.requires_grad = False
self.model.conv1.requires_grad_(False)
optim_constructor = DefaultOptimWrapperConstructor(
optim_wrapper_cfg, paramwise_cfg)
with self.assertRaises(ValueError):
optim_constructor(self.model)
optim_wrapper = optim_constructor(self.model)

all_params = []
for pg in optim_wrapper.param_groups:
all_params.extend(map(id, pg['params']))
self.assertNotIn(id(self.model.conv1.weight), all_params)
self.assertIn(id(self.model.conv2.weight), all_params)

def test_default_optimizer_constructor_bypass_duplicate(self):
# paramwise_cfg with bypass_duplicate option
Expand Down

0 comments on commit 149b950

Please sign in to comment.