Skip to content

Commit

Permalink
comment out dp
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenliang Dai committed Aug 25, 2018
1 parent 28cc626 commit df28ca5
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions main/models/fcn32.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,21 @@ def __init__(self, num_classes=21, pretrained=False, depth=18, dprob=0.1):
f.inplace = True

# Add Dropout module after each conv layer for torchvision.models.resnet
modified_features = []
for f in features:
if f.__class__.__name__ == 'Sequential':
new_seq = []
for ff in f.children():
list_modules = [*ff.children()]
for module in list_modules:
new_seq.append(module)
if 'Conv' in module.__class__.__name__:
new_seq.append(nn.Dropout(p=dprob))
modified_features.append(nn.Sequential(*new_seq))
else:
modified_features.append(f)

self.features = nn.Sequential(*modified_features)
# modified_features = []
# for f in features:
# if f.__class__.__name__ == 'Sequential':
# new_seq = []
# for ff in f.children():
# list_modules = [*ff.children()]
# for module in list_modules:
# new_seq.append(module)
# if 'Conv' in module.__class__.__name__:
# new_seq.append(nn.Dropout(p=dprob))
# modified_features.append(nn.Sequential(*new_seq))
# else:
# modified_features.append(f)

self.features = nn.Sequential(*features)

final = nn.Conv2d(num_channels, num_classes, kernel_size=1)
final.weight.data.zero_()
Expand Down

0 comments on commit df28ca5

Please sign in to comment.