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

Have questions about function “_make_layer ” ,add layers why is *for stride in strides, not for i in range(0, num_blocks): #88

Open
wupeng1989 opened this issue Oct 15, 2023 · 0 comments

Comments

@wupeng1989
Copy link

in function _make_layer ,add layers why is *for stride in strides, not for i in range(0, num_blocks):

def _make_layer(self, block, out_channels, num_blocks, stride):
"""make resnet layers(by layer i didnt mean this 'layer' was the
same as a neuron netowork layer, ex. conv layer), one layer may
contain more than one residual block

    Args:
        block: block type, basic block or bottle neck block
        out_channels: output depth channel number of this layer
        num_blocks: how many blocks per layer
        stride: the stride of the first block of this layer

    Return:
        return a resnet layer
    """

    # we have num_block blocks per layer, the first block
    # could be 1 or 2, other blocks would always be 1
    strides = [stride] + [1] * (num_blocks - 1)
    layers = []
    **for stride in strides:**
        layers.append(block(self.in_channels, out_channels, stride))
        self.in_channels = out_channels * block.expansion

    return nn.Sequential(*layers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant