Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed prev module error for resnet18 #31

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions trailmet/models/resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,19 @@ def __init__(self, block, layers, width=1, num_classes=1000, produce_vectors=Fal
for b in l.children():
downs = next(b.downsample.children()) if b.downsample is not None else None

assert block is Bottleneck
prev = self.bn1
for l_block in [self.layer1, self.layer2, self.layer3, self.layer4]:
l_blocks = [self.layer1, self.layer2, self.layer3]
if block is Bottleneck:
l_blocks.append(self.layer4)
for l_block in l_blocks:
for b in l_block:
self.prev_module[b.bn1] = prev
self.prev_module[b.bn2] = b.bn1
self.prev_module[b.bn3] = b.bn2
if block is Bottleneck:
self.prev_module[b.bn3] = b.bn2
if b.downsample is not None:
self.prev_module[b.downsample[1]] = prev
prev = b.bn3
prev = b.bn3 if block is Bottleneck else b.bn2

def _make_layer(self, block, planes, blocks, stride=1):
downsample = None
Expand Down