MCPcopy Create free account
hub / github.com/NVIDIA/semantic-segmentation / __init__

Method __init__

network/Resnet.py:140–160  ·  view source on GitHub ↗
(self, block, layers, num_classes=1000)

Source from the content-addressed store, hash-verified

138 Resnet Global Module for Initialization
139 """
140 def __init__(self, block, layers, num_classes=1000):
141 self.inplanes = 64
142 super(ResNet, self).__init__()
143 self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3,
144 bias=False)
145 self.bn1 = mynn.Norm2d(64)
146 self.relu = nn.ReLU(inplace=True)
147 self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
148 self.layer1 = self._make_layer(block, 64, layers[0])
149 self.layer2 = self._make_layer(block, 128, layers[1], stride=2)
150 self.layer3 = self._make_layer(block, 256, layers[2], stride=2)
151 self.layer4 = self._make_layer(block, 512, layers[3], stride=2)
152 self.avgpool = nn.AvgPool2d(7, stride=1)
153 self.fc = nn.Linear(512 * block.expansion, num_classes)
154
155 for m in self.modules():
156 if isinstance(m, nn.Conv2d):
157 nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu')
158 elif isinstance(m, nn.BatchNorm2d):
159 nn.init.constant_(m.weight, 1)
160 nn.init.constant_(m.bias, 0)
161
162 def _make_layer(self, block, planes, blocks, stride=1):
163 downsample = None

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 1

_make_layerMethod · 0.95

Tested by

no test coverage detected