Skip to content

Commit e0000f7

Browse files
hoonyyhoonglenn-jocher
authored andcommitted
Change isinstance method(torch.Tensor to nn.Parameter)
1 parent 54be5de commit e0000f7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

train.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ def train(hyp, opt, device, tb_writer=None, wandb=None):
9595

9696
pg0, pg1, pg2 = [], [], [] # optimizer parameter groups
9797
for k, v in model.named_modules():
98-
if hasattr(v, 'bias') and isinstance(v.bias, torch.Tensor):
98+
if hasattr(v, 'bias') and isinstance(v.bias, nn.Parameter):
9999
pg2.append(v.bias) # biases
100100
if isinstance(v, nn.BatchNorm2d):
101101
pg0.append(v.weight)
102-
elif hasattr(v, 'weight') and isinstance(v.weight, torch.Tensor):
102+
elif hasattr(v, 'weight') and isinstance(v.weight, nn.Parameter):
103103
pg1.append(v.weight) # apply weight decay
104104
for k, v in model.named_parameters():
105105
v.requires_grad = True

0 commit comments

Comments
 (0)